Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How is the long term productivity of PHP these days? I used PHP last time more than 10 years ago and it did not shine there.


10 years ago we are at PHP 5.2 days. PHP has evolved a lot since then, back then it was cumbersome, but things started to change with PHP 5.6 release and then with the entire PHP 7.x releases (skipped PHP 6) a new standard was set of language improvements, performance improvements and clean up of old bad behavior, impressive work from the core team.

In PHP 5.2 you can't even write inline callback functions, but since then you have closures, type signatures for functions (both for class types and scalar types), namespaces, short array syntax, anonymous classes, generators, null coalesce operator, typed class properties to name a few.

And with PHP 8 new leap forward with things like named arguments, attributes (similar as Java annotations), constructor property promotion, union types, match expressions, nullsafe operator.

Other interesting new stuff is FFI (Foreign Function Interface) so you can all C code directly from PHP.

Performance is also increased a lot, most notably is the array performance much better, opcache built in, but other things like now PHP has a JIT. And GC today is way better than the old days.

PHP community has also changed, lots of good frameworks and libraries and you can use composer (like npm but better IMHO) to use with your project.

You can of course write PHP as the in PHP 5.2 days if you want because new features are optional, so you can take your old code and (almost) run it in PHP 8, but if you adopt modern PHP with strict typing is as good long term as Java, especially if use something like Jetbrains PhpStorm IDE or some of the many static analyzers (psalm, phpstan, phan) that exist today.

https://www.php.net/manual/en/migration56.new-features.php

https://www.php.net/manual/en/migration70.new-features.php

https://www.php.net/manual/en/migration71.new-features.php

https://www.php.net/manual/en/migration72.new-features.php

https://www.php.net/manual/en/migration73.new-features.php

https://www.php.net/manual/en/migration74.new-features.php

https://www.php.net/manual/en/migration80.new-features.php




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: