Live data from Hacker News

A look at modern PHP

lwn.net

171–180 of 610 posts

Re: A look at modern PHP

#171
post #14

Even with PHP7, PHP still feels like it is playing catch up. There is nothing new or revolutionary in PHP7, just adopting features present in other major languages. Adopting as other newer languages like Go and Rust seems to be moving beyond those features. A catch up into a world that's on its way out, if one will feel so blunt. PHP's raison d'être remains its ease of getting an instance running on a webserver. But…

Most of the time you do not chose a language or ecosystem because it has some cool syntax or some new feature. As an example if you need to do X you look at what solves X the best, if I can do X by installing say ffmpeg and write a bash script I will do that and not cry that bash does not have some cool feature. I think languages like PHP, Java, C++ appeal for people that solve hard problem where the fact that you ha…

Yes, and all three of them has very good backwards combability, one of the most underestimated features in a language for developers but one of the most important ones for building a stable business.

I recently upgraded a huge legacy codebase from PHP 5.2 (released 2006) to PHP 7.4 (released 2019) with relatively few changes, mostly changing the use of deprecated functions & misuse of variable references.

Re: A look at modern PHP

#172

Does php still use $ for variable names in 2020?

Of course. Why change that for zero gain? Powershell does too. Can you point to some research that scientifically proves that the use of dollar sign in variable names makes it harder to solve computer science problems?

1. Waste of time and mental cycles: forces the programmer to do the parser's job because the language designer was too lazy to build in the logic to recognize variables.

2. Carpal tunnel syndrome, especially on keyboards where "$" can only be reached via shift.

Re: A look at modern PHP

#173
post #112

The amount of misinformation, false claims and unsupported statements in this thread is mindblowing for the quality that I've been used to see on HN. Here are some facts: - Symfony was the backend framework with the most contributors in 2019 [1] (yes, out of any backend framework written in any language) - PHP has more active contributors than it ever had [2] - Laravel is one of the most used frameworks in the world…

I do not do PHP and only have done a bit a long time ago, but I chuckle at the statement that nobody starts any project in PHP, only to find that a huge amount of new sites are wordpress sites, and they are a gateway to PHP. And do not discard WordPress, because it is amazing in how you can have a productive web site with no programing knowledge. After your site actually generates value then you can hire programmers to create more value. Bam, PHP to the forefront. I do asp.Net core for personal projects these days and I am so jealous of the fusion theme builders for WordPress plus the huge Eco system of plug-ins.

My day job is in embedded and systems engineering, so web is not even my thing, but I find it incredible a workhorse tool like PHP gets so much disdain. Reminds me of the answers Theo de Radt, gave to the enthusiasts: nobody cares about how cool a tool is if nobody is using it. PHP is used by a lot of people, so it is more important than my new favorite darling Nim. Even if Nim sounds awesome its useless and irrelevant from a non enthusiast point of view.

Re: A look at modern PHP

#174

Earlier quoted context omitted.

Aren't there a zillion online services that provides that product out of the box, most likely for free, only requiring a browser and some monkey clicks around? -> No PHP, HTML or web server.

By that logic, nobody needs to write any thing because there's always some "online service" to "do stuff".

I think the logic is that those served by PHP are better served by platforms. Those with advanced needs are going to use a different language.

PHP isn't being replaced so much by Python, Go, and Rust as it is being replaced by Medium, Wix, and Squarespace.

Re: A look at modern PHP

#175
post #164
post #112

The amount of misinformation, false claims and unsupported statements in this thread is mindblowing for the quality that I've been used to see on HN. Here are some facts: - Symfony was the backend framework with the most contributors in 2019 [1] (yes, out of any backend framework written in any language) - PHP has more active contributors than it ever had [2] - Laravel is one of the most used frameworks in the world…

So I take it all the things in this article ( https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/ ) are no longer relevant? For example "foo"==TRUE, "foo"==0 and TRUE !=0 are logically consistent now? Or json_encode no longer returns null for invalid input?

Some of it is still true, some of it isn't true anymore and some of it simply isn't very relevant.

Comparison still isn't transitive. Not very relevant in the real world because you simply don't use "==" unless you know what you're doing.

json_decode still returns null on invalid input, so you either have to use the JSON_THROW_ON_ERROR option to make it throw an exception instead or use json_last_error().

Both are unfortunate, of course, but it's hard to fix mistakes made 25 years ago.

Re: A look at modern PHP

#176
post #164
post #112

The amount of misinformation, false claims and unsupported statements in this thread is mindblowing for the quality that I've been used to see on HN. Here are some facts: - Symfony was the backend framework with the most contributors in 2019 [1] (yes, out of any backend framework written in any language) - PHP has more active contributors than it ever had [2] - Laravel is one of the most used frameworks in the world…

So I take it all the things in this article ( https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/ ) are no longer relevant? For example "foo"==TRUE, "foo"==0 and TRUE !=0 are logically consistent now? Or json_encode no longer returns null for invalid input?

An argument I've heard advanced for both PHP and JS is that their evil is well-documented and well-understood (e.g. one of the Facebook efforts was to write an extensive spec for PHP). Contrast this with, say, Python, which is much more nicely designed, but implementation-defined and with some gotcha areas with poorly understood and documented behavior - rarely encountered, but when encountered, hard to grok or avoid, also because they can readily keep changing from version to version (some of the corner case details of slots come to mind as an example).

I can see a pragmatic point there - anything has warts, the warts you know and don't move are easier to contend with (and lint for). I'd still pick Python for most projects in that comparison, but at a certain scale of effort I'd possibly begin to wonder about the trade-offs.

Re: A look at modern PHP

#177
post #166

Earlier quoted context omitted.

Can you link or be more clear? I assumed you are talking about the array and string related functions that are not consistent in argument order.

The parent comment is referring to https://news-web.php.net/php.internals/70691 (found via https://news.ycombinator.com/item?id=6919216 ). Quoting from that link: Well, there were other factors in play there. htmlspecialchars was a very early function. Back when PHP had less than 100 functions and the function hashing mechanism was strlen(). In order to get a nice hash distribution of function names across the variou…

Thanks, I did not know that bit of history.

Re: A look at modern PHP

#178
post #112

The amount of misinformation, false claims and unsupported statements in this thread is mindblowing for the quality that I've been used to see on HN. Here are some facts: - Symfony was the backend framework with the most contributors in 2019 [1] (yes, out of any backend framework written in any language) - PHP has more active contributors than it ever had [2] - Laravel is one of the most used frameworks in the world…

Where to begin?

- No proper connection pooling with circuit breakers.

- No proper multithreading (that works in web environment) or parallelism in general.

- Almost everything blocks (even `new PDO('mysql:...')` can block for whatever the execution time limit is, if there is an issue with connection or MySQL server).

- Most libraries are implemented in C instead of in PHP, whereas with other languages people try to avoid native code as much as possible. This means that code is not memory safe, and understanding or contributing is close to impossible.

The reason for this is because PHP doesn't support many things that are expected in any other language.

PHP C API is hard to understand, hard to use, and documentation is subpar.

- There is no way to easily share memory between processes. You have to rely on APCu (hack), because this cannot be implemented in PHP.

- Did I mention that almost anything can block? ODBC? PDO? Some 3rd party library? Even set_time_limit cannot help you here. Handling this gracefully is close to impossible.

Re: A look at modern PHP

#179
post #112

The amount of misinformation, false claims and unsupported statements in this thread is mindblowing for the quality that I've been used to see on HN. Here are some facts: - Symfony was the backend framework with the most contributors in 2019 [1] (yes, out of any backend framework written in any language) - PHP has more active contributors than it ever had [2] - Laravel is one of the most used frameworks in the world…

> PHP only exists today because of legacies being maintained

> people compare it to languages like Rust or Go since they consider those are "innovative"

PHP is getting old enough for developers today to be unaware of the history of web development. If you don't know the history, then you haven't seen the twists and turns it has taken. If you don't know the twists and turns, then you don't see how everything from the past relates to the state of the present.

Perhaps the greatest accomplishment of PHP is that the ecosystem so thoroughly solved a certain approach of web development that the rest of the world could move on to try these other ideas (which are of questionable effectiveness.) There's only so many web frameworks, content management systems and general web development libraries that you can build before you start to realize what waste of time it is to keep reinventing the wheel. PHP has an ecosystem which is still strong (and growing) because there's no need to recreate what PHP has done so well.

Wordpress as an example is not going to be replaced. You can't replace Wordpress by building something in a different language. The code base represents mind blowing knowledge which has gone into solving such problems which have nothing to do with a specific programming language. Nobody cares that you can recreate some basic thing with the new shiny. The programming language isn't the problem.

Now Wordpress is possibly reinventing the CMS with Gutenberg (like it or not) and it's not the programming language which is making it possible or hindering. PHP is a great platform to build on.

As your system grows, then your problems change. The tools required to tackle those problems change as well. This is true of everything. You can't manage a Google the same way that you manage a 2 pizza team. To get to that scale, the systems need to change many times over. PHP solved a wide problem, but it's not perfect and it's not one size fits all. Go is great at solving other problems, and it's a generalist when applied to the web domain. It's not a good comparison.

We haven't even started on the business side of decision making. If I want a web presence, this thread is doing nothing for me. I'm just going to fire up Wordpress and move to the next step. Or Laravel if I want a fast prototype, etc.

Seeing how important this history has been in my own area of expertise makes me think I better start hitting the history books which would be important for my other areas of life. If you don't know your history, then you're handicapped when discussing the present.

Re: A look at modern PHP

#180
post #112

The amount of misinformation, false claims and unsupported statements in this thread is mindblowing for the quality that I've been used to see on HN. Here are some facts: - Symfony was the backend framework with the most contributors in 2019 [1] (yes, out of any backend framework written in any language) - PHP has more active contributors than it ever had [2] - Laravel is one of the most used frameworks in the world…

PHP isn't being replaced by Rust or Go. It's being replaced by Medium, Wix, and Squarespace.

At this point, the predominant reason it's still undergoing active development is that there is a metric ton of legacy PHP code. As the businesses still using it either mature, evolve, or fail, the need for PHP will begin to dry up.

You're defending the language from an emotional standpoint.

> choosing php for a new project is a no-brianer. The only other 2 stacks to which I can compare it are the Spring stack of Java or .NET core

This is absolutely not the case, and you know it. Almost every language has a wealth of HTTP tools and frameworks, and many of them come built-in.

Choosing PHP will be like choosing Python 2. In fact, that's my 2030 prediction.

Post reply on HN