PHP is not that bad

The internet is filled with articles about how bad PHP is. Try a quick Google search for “PHP sucks” and you find about 83 million results. Doing the same search for other languages still gives you millions of results, but PHP really stands out in these numbers.

Although I agree that PHP probably is not the most beautiful language to work with (it’s getting better), PHP must be doing something right. Most of the really detailed rants about PHP date from the old days of the language. I often feel that the arguments being used to claim that PHP sucks, are the same issues when talking about bad practices for developers. Of course you can write bad code in PHP, like you can in any language.

I’m a fan of PHP, but for different reasons than you might guess. I am very well aware of the flaws in the language and cringe every time I do silly stuff like mixing up needle and haystack order in function arguments. The claim that PHP is bad is too easy for me though, because it’s simply not true.

Market share

Looking at the usage of server-side programming languages for websites, PHP really stands out. PHP is being used by over 80% of all websites that the we know the programming language of. This is not a small majority, this is an absolute victory when just looking at the data.

WordPress is now powering roughly 20% of the internet and consist for a really large part of PHP. I like to think that it’s because of PHP that WordPress has become so popular, but I think it works both ways.

Of course, I understand it’s not that simple and I’m not going to look at just the numbers. But it gives a good impression of how widely PHP is used. If it were that bad, surely other programming languages would be closer to PHP when it comes to market share, right?

Maybe it’s more fair to have a look at the TIOBE community index, where PHP currently sits in sixth place. PHP used to be more popular in that index, but it’s still ranked higher than Ruby, Python and other languages that are often claimed to be ‘better’ than PHP.

PHP suffers from the past

Besides the millions of search results for “PHP sucks”, there are also over 100 million search results when searching for “PHP tutorial”. I think that about 99% of these tutorials are based on old PHP versions, have flaws in the described code and generally shouldn’t be available anymore. But they are and we need to deal with it.

All these tutorials, outdated and plain bad examples are the real problem for PHP. Yes, PHP has namespaces, closures, traits and many more cool stuff that developers love. The vast majority of the content on the internet doesn’t use anything of this though.

People now getting started with PHP will likely use Google a lot. Heck, I use Google a lot still. Less experienced developers will find these outdated tutorials and will learn PHP that way. They basically learn something that should be done differently if learned today.

It’s about code, not about languages

To me, a programming language is as bad as the code people write in it. You can write pretty good code with PHP, just like you can in Ruby, Python or whatever fancy language you want to write it in. I’ll be one of the first to say that I prefer Ruby syntax and structure over PHP, but that doesn’t mean PHP is bad.

As a developer, it’s your job to write good code. If you are using PHP for a project, you can still write good code. If you decide to use Ruby, you can write good code. It’s time to leave the PHP legacy behind us and focus on how we can use PHP for our projects. PHP is here to stay, if we like it or not.

Bottom line is, as explained by this tweet by Jeff Atwood, it’s all about preference.

5 replies on “PHP is not that bad”

  1. Thanks for writing this down, Coen.

    Thing is, when writing websites in Java/Ruby/Python, you have the advantage or disadvantage that you can do more with the standard installation. More access to the operating system, execution of binaries. Due to the handy design from the beginning of PHP preventing those things unless you wanted it to do so, a lot of hosting companies provided preconfigured installations you could use for running your site. Very handy for the hobbyist, small businesses et cetera.

    The other languages needed a virtual or dedicated server to run properly. Much more expensive. But when you want the same amount of flexibility with PHP, you will need those too.

    Saying PHP is good or bad does with the amount of websites running with it is in my opinion a bit weird. What you could say with that argument, is something like: with PHP it is very easy to quickly set-up a site.

    Just a few cents. Now lets discuss tabs versus spaces (both, altering them for odd and even lines) or emacs versus vim (magnetic needle wins here).

  2. PHP permits really bad programming. But it also permits really good programming. The real problem people seem to have with it is that it doesn’t hold their hand and force them to be good software architects/programmers. Seems to me the solution lies with the programmers not the language.

  3. Great Article! PHP might have faults, it might even be bad from a lot of different angles although most of the complaints are just silly religious regurgitation posted by kids based on nothing but ignorance…., but you can’t get around the fact that it is still the undisputed champ for web development. If there was anything out there even remotely as “bad/horrible”, everybody and their uncle would be using it. But they don’t, because there isn’t…! And that should tell all the haters something about themselves. I think all the idiot know it all should get together and create a language that blows PHP out of the water. Why haven’t they done it already? I mean apparently all the odds are in their favor. Plus, who in their right mind would say no to something like that…

  4. Wrong

    If you want to write good PHP, the language will stand in your way and make you work hard for it.

    If you want to run secure PHP, good luck as that is impossible.

    PHP: for amateurs, by amateurs

  5. You can get a decent VPS for < $5.00 a month and a really good one for $10-$15 and shared hosting sucks in every possible way.

    Like PHP, Shared hosting is for amateurs.

Comments are closed.