Why you should NOT choose PHP for your next project

May 14th, 2012 | by | unrelated


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.[1]

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.

Authored by

  • Scott

    I understand you really don’t like PHP, but your very specific to the language. When really, a good programmer is a good programmer regardless of the language, but, like everything in programming you must pick the language that suits. That is often PHP for web development on linux.

    It just so happens that PHP gives you a lot of freedom which tends to shoot itself in the foot because of how easy it is beginners tend to learn the syntax but can’t write code! Java for example has a much higher learning curve and tends to be taught more professionally. PHP gets tarnished by beginners abusing it.

    I completely agree with “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.”. Something many people miss.

    The main reason a project dies is NOT BECAUSE OF THE LANGUAGE, but because it was written by poor developers and/or rubbish idea for a project in the first place.

    Give PHP a break, half the sites you know today probably wouldn’t exist today if it wasn’t for PHP ;)

    • A good programmer is a good programmer, but a good programmer with the wrong set of tools is helpless, just like a sailor with a sail full of holes, or the carpenter with an awkward toolbox.

      I’ve personally reached the limitations of PHP countless times, or wasted my time working around weird implementation, undocumented features, unexpected results, etc…

      I saw one or two project fail miserably exactly because they were implemented in PHP – the language was just not strong enough to handle the load.

      “everybody does that” is not a good reason to do something, and if you do your research you’ll see that behind the PHP frontend of many sites, there’s a complex backend written in C, Java, or something else.

      PHP is a nice languages to get your foot at the door, or if you need to write a small script – but so are JavaScript, Ruby, Python…

      • Scott

        Thanks for the reply :)

        “I saw one or two project fail miserably exactly because they were implemented in PHP – the language was just not strong enough to handle the load.”. Sure that wasn’t apache, lighttpd, etc and not the language itself?

        I must admit though, i do wish PHP would have features such as Threading, type hinting for primatives (though that will never happen due to how PHP automatically type casts) and built in unicode support. Is a bit of a messy language with function names too. Moving on swiftly lol.

        Using your analogy of a sail with holes in it – if that were the case i doubt that “sales with holes” in would ever become mainstream. What i’m saying is, PHP would never have got the traction it has now if it had such “holes” in it. Before you say PHP got their first – Perl and C were commonly used before PHP to do CGI. However, PHP beat them!?

        I’ve never found the language itself to be the problem speed wise, but the architecture (database, server, etc)… not the language?

        P.S. Nice blog design by the way, nice and clean looking :)

  • Mehdy Meds

    What does your website use?

    • danielrozenberg

      I didn’t choose to develop a project in PHP, I used WordPress, an (amazing) project that uses PHP. I salute the developers of WordPress :)