Proper compiler to catch issues. Compilation is such a cheap and quick thing, not having it is a pain.
Generics
Proper strict typing
PHP still runs on a lot of indirection, which makes it unsuitable for a lower latency scenarios
Persistent memory - also solvable
Ecosystem is bad. Where are a lot of drivers for example which either run out of process (slow) or do not have connection pooling (uter shit).
All in all PHP lacks a lot of things for high perf, low'ish latency web. For small sites and sites where perf and latency are not important php is fine.
Please do not go - but facebook, but 90% of web and so on route.
re: compilation, the best alternative (and covers everything in this aspect, imo) is phpstan and psalm, the static analysis does a lot of the checks that a compiler would
It does, but it also does not. Its a step behind. Also PHP allows you to write code which is can not be statically checked no matter that. Under normal circumstances you should not do it ofc.
Honestly a similar issues can happen with complied languages if reflection is used, its just that in PHP "normal" code can lead to this.
What makes it worse is that even ignoring everything you mentioned, PHP is also less ergonomic and requires typing much more code than modern alternatives like Scala, Kotlin, TypeScript or even Java.
People think a proper static type system makes it harder to code, when it's really the opposite. And yeah there is a reason why FB had to create their own entire new language called Hack, with static types among other things to cope with the absolute tech debt they incurred on themselves.
Well to PHPs credit they are moving forward. Enums got added in 2024 (!), where are serious talks about generics, lambda functions are less cumbersome. Give it 5 years and it will be fine. But even after that some core issues will remain, like ZValues. No matter how you dance this will always going to handicap PHP for more serious bespoke scenarios.
Also if you think about say Java or C# or Go, you can write everything in your company using that one language (except web UI, because javascript), with PHP you will eventually be forced to adopt another language for ETLs or to do something PHP was never meant to do.
Long running async php stuff remidies that issue some that. But it creates another one. Namely drivers. Somone who writes some driver related to IO is kind of forced to assume non long running environment. So you run into issues, with having async, but not having drivers.
99% people here will start talking about - but mariadb works and what not. Where are plenty of other dbs which just do not have good drivers for PHP, in some cases do not have official drivers at all, because they assume that PHP will not fit the scenario anyways.
Those type of issues can not be solved by PHP foundation alone, whole community has to switch their ways, and PHP community (not everyone, but most in my experience) is known to be stubborn and ignorant repeating same mantras again and again. Once people here realizes that php-fpm must die for php to advance it will have a really good chance to be more than wordpress or a best way to make e-shops.
Most useful unboxed values (save perhaps packed arrays) are likely going to be allocated on the stack, so no refcounts needed and no COW happening. Some objects could potentially live on the stack too, but practically speaking PHP would probably need a new Record type with value semantics to achieve it. That's a topic that comes up every now and then but it's never gotten to the RFC stage afaik.
>Technically you can enforce this on your project if you set strict_types = 1 Can I write that function returns string[] without extra lines of code and hints? I can not. Until when its not strict typing.
>PHP is not a compiled language so I don't even know what you mean here. Its like saying I'm not in shape and its fine. Which is true, but does not make stuff better from the perspective of a fit person.
Advantages of "scripted language" are no longer relevant in modern web development (or at least benefits outweigh the cons). PHP could be compiled and would be better because of it. A lot of people will going to argue about this, but they also have not worked with modern compiled stack.
I for example deploy C# app faster to production than PHP people, because my tests, lint, coverage and other CI/CD things run faster on same agent. It takes me about 1 minute less. PHP app does roughly the same steps and is roughly the same complexity, but has few hundred more tests (which in C# would add ~10 seconds to runtime of pipeline).
Not a difference that matters (it does not), but still its ironical.
View all comments
5
u/Miserable_Ad7246 Dec 29 '24
All in all PHP lacks a lot of things for high perf, low'ish latency web. For small sites and sites where perf and latency are not important php is fine.
Please do not go - but facebook, but 90% of web and so on route.