Despite having a myriad of problems, PHP is still the most popular choice for new web based projects. Whenever someone asks my opinion regarding the language of choice for a new project, I immediately shy away from PHP and suggest something else that fits the project well. Yet many end up blindly choosing PHP, often for the wrong reasons, for example:
“PHP is an industry standard”
… and so is polluting river water. Just because PHP positioned itself as an industry standard doesn’t mean it’s a Good Thing. Choosing it because of that reason misses the point, you are not trying to choose a programming language for everyone. You are trying to choose a programming language for your own project.
“But facebook uses PHP!”
Google uses Java, Apple uses Objective-C, Microsoft uses ASP.NET. One (or a million) success stories of a company that just happens to use PHP does not mean “1. use PHP ; 2. become rich”
“There are a lot of great tools built on PHP, such as WordPress and Drupal”
These are indeed great tools (this very blog uses WordPress,) they are easy to install and easy to use by non-developers. Your project might even work well enough by just downloading Drupal and installing some contributed modules, in which case PHP is the best choice in the same way that premium gas is the best choice for that new Toyota you just bought.
If you are creating something a bit more complex, remember that Drupal and WordPress are in constant development for the past 10 years, and they started out back when PHP was the only legitimate choice if you were against Microsoft technologies. Who knows if they would have made the same choices today?
“My client wants it”
This one is a bit tricky. Your client wants something stable and maintainable. Your client wants to know that if you begin to overcharge them on maintenance, they can replace you (and that’s a Good Thing!*). Your client just read an article in some business magazine that mentioned PHP as The Best Thing Since Sliced Bread.
PHP isn’t stable and isn’t maintainable. If you believe you can cut costs and development time by using a technology that is really stable and maintainable, convince your client.
If your client insists, well…
and of course, my personal favorite:
“I personally prefer Python**, but there aren’t a lot of Python developers around”
That’s just wrong thinking. Whenever a new developer joins your project there is a period of several weeks when the new hire is learning. Their effectiveness at this time is laughable. Developers can learn new languages and tools, as well as your own project, in a surprisingly short period. Just give them a chance!
When you are looking for team members, don’t look for the languages section on their cv. Ask yourself if they understand the MVC architecture, if they can write efficient asynchronous methods, if they know when it is proper to sub-class, etc.
If your project is using PHP, would you choose the person with 5 years of PHP experience? Or the person with 1 year of PHP, and 10 years of Python, Java, C# and Haskell? What if the latter had no experience with PHP? Would you still think this person is unsuitable for your PHP project? I’m willing to bet that your answer is “no”. So why choose PHP because there are more developers who use it?
Obviously this example was reduced to the extreme basics, but the point is still clear. Do you really want to choose your project’s technology because you can’t afford two weeks of little productivity for new hires? You’re just cheating yourself into thinking you can skip this slow period.
I think PHP should die. Rasmus Lerdorf, the person who came up with PHP, once said:
I’m not a real programmer. I throw together things until it works then I move on. The real programmers will say “Yeah it works but you’re leaking memory everywhere. Perhaps we should fix that.” I’ll just restart Apache every 10 requests.
If this doesn’t cause you to raise your eyebrow, this post isn’t for you.
What should you use instead? Use Django, use Ruby on Rails. My personal experience with these two made me very happy. Use node.js, use ASP.NET, use Java. Don’t use PHP. Your developers will thank you.
* If your company grows and you want to increase your charge rate, it means that maybe that old project is just a hassle for you to maintain at this point
** … and it’s always Python when this reason is used
This post doesn’t belong in this blog’s standard subject, but I recently finished my 4 year run at a company that uses Drupal and PHP exclusively. I personally stumbled on many of the problems described in the blog post linked to in the first paragraph, and lots of people recently asked for my opinion regarding their choice of technology for their next project. I decided to put this in writing and publish it so I can easily refer them here.
I also decided to bluntly refuse any job offer that touches PHP. I want to distance myself from this world. It’s a principle thing.