Hacker News new | ask | show | jobs
by ars 3307 days ago
No PHP is hated because it's too easy to use.

The means that a lot of rather bad (inexperienced?) programmers use it, which means there is a lot of bad PHP code out there.

People see that bad code and assume the language is bad.

The language has some warts and inconsistencies, and people are eager to point them out as justification for their hate. But for real programming most of them hardly matter.

1 comments

this is something a bit naive - basically all dynamic languages have the same low barrier and can produce the same crappy code, see for example javascript or ruby (with RoR). Python too, considering the fact that it's used by a lot of people that their main job is not software engineering.

The biggest difference between PHP and the other dynamic languages, though, is that PHP came out with pretty popular stuff like wordpress, joomla, magento or drupal that they all share crappy code coz they all have a large codebase started before PHP managed to fix some stuff starting from version 5.3

Python is as easy to write as PHP, but deploying it as a web app is a whole different story.
That comparison is complicated: it's definitely easy to drop a .php file on a server but once you start talking about frameworks, using a newer version than your OS distribution shipped, adding C extensions, etc. it's easy to find counter-examples, and the Go proponents are not wrong to observe that deploying a single file is easier than either.

This is also becoming less of a distinguishing factor in the container era where the answer for a number of cases is “Extend a base Docker image”.

At least PHP offers that option at all, and it's well-supported and well-documented. It's also very easy. Good luck doing the same with any other language.

If you really, really try it's possible in Python, C# and Java too, but ... wtf.

Note that I didn't say it wasn't a selling point for PHP. It's just that I can count on no fingers large PHP projects I've seen where deployment is still that simple – and that's generally not a problem because with modern tooling (e.g. Ansible) and deployment options (e.g. containers) you're under less pressure to make that a deciding factor for your application.