by idoubtit · 1w ago · 0 comments
1. more complex to use (it took years for some parsers to implement the PHP 8.4 property hooks, and I suppose few people can explain how they work with inheritance and traits), 2. more costly to maintain (I remember when the developer of PHP's JIT left, the PHP foundation was worried because no one could understand the JIT code), 3. and has more security risks (critical security releases will continue).
I don't disagree with you, but the situation is more nuanced, and PHP's initial promises are now blurred.
> 1. A stateless functional core. It's cheap to run and quick to start.
Most modern codebases use a framework. And once you have to load Wordpress, Drupal, or even worse, Laravel, then it's no longer cheap and quick. So PHP added several layers of complexity to mitigate this: an opcode cache, a code-preload system...
> 2. Every request has an environment created then torn down.
That's no longer always true. When the code preload is enabled, a request can leak into another.
> 3. Every request is single-threaded. [...] Async network/IO requests are handled via extensions.
You mixing up two different things. The default PHP SAPIs have single-threaded request handlers (though IIRC the default deploy stack of Laravel differs). But the language has a native async feature through Fibers, from which coroutines can be implemented (see amphp/amp).
So PHP on the server side is usually like JS on the client side (except for workers): single-threaded with async. Though I haven't seen much use of Fibers in the wild, it's in the language.
The frameworks aren't slow: https://tideways.com/profiler/blog/php-benchmarks-8.6-vs-8.5...
The last round of TechEmpower web benchmarks computed the framework overhead. Depending on the task, the performance of Laravel was 5% to 20% of the native PHP code, i.e. 5 to 20 times slower. Source : https://www.techempower.com/benchmarks/#section=data-r23&tes...
The TideWays benchmark doesn't show the peak, it shows the rps for 15 sustained users.
Yes. And it's also not entirely representative of a production set-up. As an example Vegata is running on the same machine as PHP and the same is true for the MySQL server used by WordPress and Laravel. The tests are also running against a - except for worker count - stock installation to possibly highlight improvements by better INI defaults in newer PHP versions. This is all good enough to compare the different PHP versions against each other, since they are all equally affected by this. But it is thus by no means representative of what you can get out of a properly tuned production setup.
Disclosure: I set up the benchmark and performed the measurements. PS: It's Tideways, lowercase 'w'.
We have a Symfony REST API responding in 20ms for 30-40k requests per minute.
Yes there are use-cases outside this scale where Go (or others) is better suited from the start, but its not universal deal breaker.
That's in the same bucket (to me) as, say, L1/2/3 cache leaking between CPU threads. That's resulted in real attacks but it's not really the fault of my programming. I would rather the bug be in the language or the compiler/interpreter or even the framework because it's more likely to get found and fixed than if it was only code written by me for me.
As an aside, PHP eliminates a whole class of bugs that don't exist in, say, C/C++ eg string buffer overflows. Yes, the PHP engine can itself have buffer overflows but as per my previous point I trust the library developers and the volume of people who use and analyze it more than being totally correct with my own string handling.
> But the language has a native async feature through Fibers, from which coroutines can be implemented (see amphp/amp).
Only a single fiber runs your PHP request at any one time. This still fits the same model.