|
|
|
|
|
by cletus
684 days ago
|
|
It's disappointing that PHP still gets hate in 2024. PHP of 2024 isn't the PHP of 2004. As someone with a bunch of experience in Java, C, C++, Python, PHP, Hack, Javascript and a handful of others, PHP is (IMHO) almost a perfect language for serving HTTP requests because of these characteristics: 1. Essentially an HTML document is a valid PHP program. This is an excellent starting point for beginners; 2. PHP has a stateless API that means there's basically zero start up cost, unlike, say, loading libraries like you do in Java or even Python; 3. There's no threading within the context of a request. This is what you want 99.99% of the time. Hack extended this with cooperative async/await; 4. Because of (3) everything you allocate/use within a request context just gets thrown away. There's no persistent state (eg like Java's servlet model). Again, this is almost ideal; 5. Because of all the above, PHP hosting is incredibly cheap and accessible. The two things I'd probably add to PHP come from Hack: a modern type system with nullable support and the collections (vec, map, set). |
|
Regarding embedded into HTML PHP code - it's a easy for beginners but in a large application it leads to hard to maintain mix of app logic and presentation - AFAIK this feature is rarely used outside toy project for many years.
[1] https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/ (very old and some issues may be were addressed but it's hard to fix all of this without creating an incompatible language)