Live data from Hacker News

PHP is worth learning and using

bulletproofphp.dev

411–420 of 468 posts

Re: PHP is worth learning and using

#411

Hey if you don't like PHP please don't use it. I 'd hate to bring the culture of tiny packages, fake compilers, transpilers and weekly trends to PHP. Personally I use php because it works well and fast and still supports my 10 year old websites, not because it's cool.

Php change from 4.x to 5.x broke my web sites and I still don't trust php after that. I guess they might do it again from 7.x to 8.x, we'll see. If having the same code working for a long time is the most important for you then you should probably use java or .net. Maybe c++ also but that is not as popular for building web apps.

I found the transition from 4 to 7 oddly easy, but that might just be the conventions i was using. I don't know about 8, don't plan to use it until i have to

Re: PHP is worth learning and using

#412
post #384

Earlier quoted context omitted.

Frankly my reasons for using it boil down to: 1. WordPress uses it 2. PHP is far less terrible than I remember (having used it in very early days) I manage a WP (woocommerce) site for a small business. It's not my day job, it needs to be simple. Most of the "day job" is handled by content management users. I have written a fair amount of plugins though to enable custom functionality and the process is perfectly fine.…

I would not recommend anyone to use WordPress in 2021, though. WordPress maybe simple to setup, it's part of what gave PHP its bad reputation.

Yeah, I hear that a lot, and to me it always seems like a person curling their lip in disapproval from the nearby Ivory Tower.

I honestly always wonder: as opposed to what? Let's take my simple requirement, a small business ecommerce store that's not going to look like trash and where non technical users can make pages, edit descriptions, etc.

I can do: WordPress, Magento, or I can pay a SaS provider. Essentially both do it yourself approaches are PHP and Magento has really sabotaged itself with the complicated migration. SaS means higher costs and if I want custom functionality (and yes, the business needs it), it ranges from impossible to possible but a headache.

So here is a business that is now online for a minimal cost for two years, allowing great flexibility for me, while allowing completely non technical users to get crap done.

Re: PHP is worth learning and using

#413

| php is fast. https://benchmarksgame-team.pages.debian.net/benchmarksgame/... it's faster than python, but my grandma is too and she died in 1993. However, function calls are extremely slow. If you would bench something like a naieve fibonacci implementation (or ackermann's function) you would be surprised.

I have stopped trusting the aforementioned link because they play dirty games with benchmarks, most of the times. Let me give you an example; https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/regexredux-python3-2.html and https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/regexredux-perl-4.html The Python code uses ctypes, thus the unfair marginal difference. I have seen the same un…

> … because they play dirty games with benchmarks, most of the times

No they do not.

Let me give you an example:

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

*** You ignored the Python code that does not use ctypes.

> I have seen the same unjust comparison with the majority of the examples…

No you have not.

There are 10 different tasks.

pidigits accepts the use of third-party libraries (GMP)

regex-redux accepts the use of third-party libraries (PCRE)

That's 2 out of 10.

Re: PHP is worth learning and using

#414

PHP needs a proper type system with generic support, and would be a killer programming language

https://hhvm.com/

I'm aware of Hack, but I don't have full control over the stack, so having all these features included in core PHP would be the only way in my case.

Re: PHP is worth learning and using

#415
post #280

Earlier quoted context omitted.

(naieve fibonacci) like this: just did some measurements on my laptop: | Language | n | time(s) | |----------------------+----+---------| | php (7.4.25) | 42 | 422.0 | | python3 | 42 | 90.0 | | haskell (ghc -O3) | 42 | 13.8 | | f# | 42 | 5.6 | | ts | 42 | 2.8 | | ocaml (ocamlopt -O3) | 42 | 0.98 | | C (gcc -O3) | 42 | 0.66 | (edit: added php version in table. )

This is what I get locally: time php fib.php 42 23s time python3 fib.py 42 1m1s I suspect that you're doing something very wrong, like running PHP with an active debugger or similar. If we're talking in comparison to slow interpreted languages like Python, then function calls in PHP are not particularly expensive. Debuggers can make them quite expensive though. Edit: Just to note, PHP's execution time drops to 4s wit…

Likely. I tried the benchmark and saw runtimes of over 5 minutes before realizing that XDebug was active and in develop mode. Adding `-d xdebug.mode=off` dropped it to 26s. That was with `opcache.jit` in the (default?) `tracing` mode. Turning it off didn't change the runtime, which is a bit puzzling. This is all with PHP8 on macOS, although I tried 8.1RC in docker and saw similar results.

Something doesn't quite add up across everyone's results here, but the extremely slow result at the top of the thread is almost certainly a debugger slowing things down.

Edit: I was missing `opcache.jit_buffer_size`, and saw the runtime drop to under ten seconds with that correctly configured.

Re: PHP is worth learning and using

#416
Too little, too late.

PHP has nothing to offer. They HAVE cleaned up some of the idiotic behaviour, but much of it still remains.

The stdlib is very poor, and having last i looked everything was still global. Some array functions like map/filter had arguments in the wrong order.

Unicode support is not there. Its a web language for gods sake! How about focus on that as a high priority?

PHP lacks a vision. What does PHP want to be/become? It looks like sometimes PHp steals Javalike features, implements them adhoc and badly, and then again sometimes more scripy features from JS.

The typ system is VERY mediocre. You really cant trust it, at least not with the stdlib.

The execution model of PHP is still living in the early 2000s. The web is real time, and PHP cant handle it without hacks, and even then you cant use any builtins like PDO (blocks thread) or any IO related feature.

Honestly, even if PHP today is ”better” than it was 10 years ago, what does it have to offer? There are multiple better languages for the problem PHP solves, and the other languages have ALSO improved in the last decade.

I cant see myself starting a new project with PHP, there is just too little it offers, and too much thats still broken, and wont ever be fixed because of BC that PHp tries so hard to keep.

Re: PHP is worth learning and using

#417

To me personally PHP is the cheapest way of building a dynamic website. Just a few euros/dollars a month will get you a shared web hosting plan with full support for the LAMP stack & free email.

That was true in 2004. Today you get a virtual server for five bucks a month. Feel free to run ANY stack you prefer.

Re: PHP is worth learning and using

#418
post #60

Earlier quoted context omitted.

Tons of sites are written exclusively in Python. Django alone has 60k stars and 25k forks on Github. That about the same as Laravel.

A quick search came up with an order of magnitude more sites in laravel than django. And combined are still a small fraction of sites on the internet.

Whichever way you spin it, building web stuff is a perfectly normal thing to do with Python. Thousands of companies do so, even big famous brands like the aforementioned.

Re: PHP is worth learning and using

#419
A simple sniff test thats tried and true still holds. ANY programming language that requires you to use a framework to actually be productive fails the test.

PHP is doing very poorly in this realm. How many PHP websites out there are actually using a few libraries and the stdlib only? Not many.

Its frameworks, frameworks frameworks. In the PHP case its actually even worse, as there are a multitude of CMS sysytems that some people use. So its not even programming, but point and click and copypaste.

Thats not a tool i eant to use in 2021.

Re: PHP is worth learning and using

#420
post #298

Earlier quoted context omitted.

Comparing Rails to PHP is unfair given that one is a framework and one is a programming language. Compare PHP and Ruby or Rails and Laravel to keep things apples to apples and oranges to oranges.

A lot of people 10+ years ago were building websites by interpreting PHP and using the output as HTML. The language (at the time) seemed to encourage this. I agree that PHP is not a framework, but it seemed to have some opinion on how HTML was to be generated, which most languages don’t have. Also rails is 7 years older than Laravel, so my point still stands that PHP was behind the curve.

10+ is not that long time ago. There was already Zend Framework. And for some basic API using framework may be overkill anyway.
Post reply on HN