Solving The PHP Problem

“PHP Sucks!” – A lot of people

PHP is a language with a bad reputation. This isn’t a story like we often see in movies. Where someone has gotten a bad reputation from life circumstances that just weren’t fair. Then they have a chance to redeem themselves. I believe PHP has earned the bad reputation it has. Have you looked at the code powering many of the most popular PHP projects in the world. I develop in PHP and reading some of these codebases makes me very very sad.

But, PHP is popular. Extremely popular. According to W3Techs:

PHP is used by 77.9% of all the websites whose server-side programming language we know.

Jeff Atwood (a.k.a. Coding Horror) just made the observations that while PHP is bad it is pervasive and has an ecosystem because of that. Other languages, some much better than PHP, just don’t have that.

So, how do we solve this PHP bad code problem?

Atwood notes,

The best way to fix the PHP problem at this point is to make the alternatives so outstanding that the choice of the better hammer becomes obvious.

He even goes on to say that helping this happen is a goal of his next gig. But, what if he fails or it takes a long time? What if PHP keeps it’s continued dominance for quite some time. After all, when I first quoted W3Techs a few months ago the number was 77.5%. PHP usage as a percentage share has grown.

An Alternative Approach

First, I wish Atwood and others the best of luck. I hope that some day I’m using a superior language to PHP that’s just as available. I look forward to that day. I’ll be happy to join in with an effort I find worthy.

But, that time has not come and we are living in a world surrounded by bad PHP code. A lot of it. Some of which I’ve written. I’m going to suggest three things.

  1. If you like C (and can stomach the PHP source code) dive in and help make it a better language. PHP is often design by committee (I’m not saying this is a good thing) meaning you can contribute to making it better.

  2. If you are writing PHP what are you doing to write sane, usable code, that’s well written? Are you looking into tools like Composer to dependency management? Are you writing modular libraries that can be easily reused? Are you using dependency injection or other relevant patterns?

  3. How are you promoting good coding habits with PHP? Do you even know the good habits to promote?

I do wish Atwood and others the best of luck. I truly hope they succeed. But, in the meantime there is a lot of PHP development happening. Let’s see if we can make coding in a PHP world something a little bit better.