The PHP defenders' mentality and seeing the light

Today I came across Mark Litwintschik’s post titled Abandoning PHP for Python.

What Mark says resonates with me in almost every paragraph but what led me to write this post was what I read in some of the comments there.

It’s a shame that some PHP fans insist on not understanding that when these comparisons are made and people say “X is better than PHP” (X being some framework like Rails or Django), we’re not really comparing PHP (the language) to that framework. They cry that it’s an unfair comparison, and that we should be comparing X with Laravel, Symfony or some other PHP framework. Sometimes it’s even comical how desperate those people sound by trying to defend their beloved PHP with ridiculous arguments. If only they admitted to PHP’s faults and used some of the actual (few) valid arguments to defend PHP, it would make much more sense. The whole “you can’t compare PHP with a complete framework” argument, despite making perfect sense, has become the life buoy of PHP fan-boys.

What they don’t understand is that the comparison, if unfair at all, would be unfair to the side of X and not PHP, because what we mean when we say “PHP” is actually the whole ecosystem and community, the best frameworks built on it, Composer, FIG, etc. So you’re actually free to choose what from the PHP land you want to compare X to. Because no matter what you add to the PHP side of the comparison, only in very few situations will PHP come out on top. Does that sound unfair?

I’ve been using PHP for over 14 years and for a while now I’ve been using Laravel 4 exclusively when dealing with PHP. Laravel, Composer and FIG standards are probably the best things to have ever happened in the PHP world but try to find good quality Free software PHP projects or packages and if you know anything about programming, you’ll quickly realise that although things are much better, it’s not that different from 5 or even 10 years ago. You will find dozens of projects trying to achieve the same goal, each one doing it in its own way, dividing efforts instead of working together, and amazingly, most of the time, none of them doing it right. This and many other things are in stark contrast with other languages, where you can easily find good quality packages for your needs and they are usually well done. Usually. It’s important that I stress this: by no means do I consider Python, Ruby or any of the frameworks written with them to be perfect. But the difference is just too great to ignore.

Yes, PHP is really popular, yes, there are great projects in PHP land and yes, it can get the job done. A really (really!) good carpenter can also create an entire set of furniture using only a knife and a fork, but just think how much less time it will take him and how much better the final result will be if you give him a proper set of tools. It’s exactly the same problem with PHP - any decent programmer can use it to create web applications and really good developers can actually make it in an elegant way, but just imagine how much better it would be if they had even better tools!

What I would really like these people to see is that you can also get the job done with other tools; that you actually get the job done faster, with less headaches, and that you will actually become a better programmer due to not following PHP’s madness and following good programming principles instead. You can think of it as taking a few classes of algorithms and software engineering on a computer science course, whereas PHP is more akin to falling into a freezing river full of piranhas and using that to learn how to swim - you’ll get there because your life depends on it, but you’ll never learn it properly and will be laughed at by those who actually know how to swim, every time you go to the local swimming pool.

I kind of understand why people ferociously defend PHP: it’s the tool they use to earn their keep and, just like some religious people are incapable of or refuse to argue rationally and logically about religion because they don’t want the foundations of their world shaken or even taken down, some PHP defenders also don’t want to see their world crumble down. People are afraid of change, everyone knows that, and I think this mentality is just a manifestation of that, even if subconsciously.

When some years ago I finally decided to try Python for web development, I was awestruck. I was obviously still much more productive with PHP than with Python because of my experience with the former but I could see the potential and I wanted it! Fast forward a few years later and while using PHP and Python in parallel, I could actually see the difference in productivity, simplicity, maintainability and clarity in my code. My experience with PHP was still far greater than my experience with Python but even so I was able to create a fully working application with Python in half the time I created it with PHP. I’m not talking about a pet project, this was actually a project for a paying customer. Now that I knew, now that my eyes were open, what was I going to do? Ignore the facts? Bury my head in the sand and keep defending PHP like my life depended on it?

I think this is what PHP defenders need to go through: an eye opening experience with other tools, be it Ruby, Python or whatever decent language they decide to try. If you experience it and decide to deny it, you’re either stupid or you’re being forced to stay with PHP. No one in their right mind will stick to it after “seeing the light.”

That’s why in my recent “I hate PHP” post I recommend that people try Ruby and Rails or Python and Django. I sincerely believe that there is no need to waste time with PHP when so much better options are as easily available, if not more easily, and that if people try those other tools for a while, they will hopefully get a moment of enlightenment and understand why so many other web developers say what they say about PHP.