This is not another “PHP Sucks” article

PHP is Broken

Pretty much every week there’s a new article trending in HackerNews with someone’s rants on PHP . Some are well formulated and well-grounded while others are just vague texts with no real arguments, just basically saying “PHP is broken” without any strong reasons, alternatives or solutions.

I’ve been working with web development and mainly PHP for around 10 years now, I’m a Zend Certified Engineer (as if the term “PHP Engineer” makes any sense) and also a Computer Scientist (which theoretically means I’m supposed to know how to build software in the “correct” way), so I believe I have enough base to write a neutral and realistic analysis of PHP and that’s the idea of this post.

One third of the web runs on PHP, it’s used in small and big websites, pretty much every hosting service supports PHP and it is usually a valid option to consider when all you need is to get things done ASAP. But just like anything else in the world, it has problems.

There are only two kinds of programming languages: those people always bitch about and those nobody uses.

Bjarne Stroustrup

If we look closely and without any prejudgement there are somethings we need to analyse: PHP is popular but it’s not cool. And that is quite a bad position to be, it’s the same situation of MS Windows for example: both are OK, accessible and serve a lot of people reasonably well, but people don’t usually enjoy them nor are really proud of using them and everybody loves to hate them.

However, it’s not difficult to understand the origin of PHP’s problems, they come from the very first days of the language with the philosophy around it. Unlike most of the traditional programming languages, there wasn’t brilliant people involved nor much thought put into it:

I don’t know how to stop it, there was never any intent to write a programming language […] I have absolutely no idea how to write a programming language, I just kept adding the next logical step on the way.

Rasmus Lerdorf

So, it is definitely not a language for purists or scientists, but it lets you get things done in a quick way and, if you are a decent programmer, with a short and clean code and also with a decent performance in most of the cases.

The fact is that any language has its quirks [1] and it’s up to you, as a developer, to know well the tool you are using. The biggest issue here is not that the language you use has problems (because all of them have) but instead, that you don’t know which are those problems and pitfalls. That is something really typical of “single language programmers” and people that take things for granted, for the lack of deeper knowledge, don’t realise what’s going on and that things can be done in a better way.

In a very personal opinion, I believe PHP is a game changer in the history of the Web as it changed the way we develop software in this era and the whole paradigm of this industry. But with the poor decisions and indifference to the “state of the art” displayed by the core developers, PHP is now behind the others in many aspects and honestly, at least for me, it’s no longer my personal language of choice if I would start a new project or my own company/startup.

References

  1. WAT – Destroy All Software Talks

Aritle year- 2012