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), they’re not really comparing PHP (the language) to that framework. PHP fans say that it’s an unfair comparison and that we should be comparing X with Laravel, Symfony or some other PHP framework, sometimes even relying on very poor 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.
What they don’t seem to understand is that the comparison, if unfair at all, would be unfair to the side of X and not PHP, because what people mean when they 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.
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 in some ways, they’re mostly 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 other language or framework 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!
The message I would love to be able to get across, and what I think hardcore PHP fans are missing, 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.
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. Human beings are afraid of change, especially if that change can be perceived as representing some danger to their existence - “if I can’t use the tool I know, I will be out of a job, homeless and hungry” - 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.