Hi. This article was written a year ago. To get with the times, I wrote a follow-up to this article

PHP is dead. Probably.

Allow me to preface this with some context. I <3 PHP. It's probably my favorite language for a variety of reasons, but the number one reason being I'm pretty expert at it. But I'm not above recognizing that the majority of PHP programmers are generally idiot script kiddies, and don't know how to write code that is not terrible. In that way, all PHP programmers get a bad name, because, like in all other aspects of life, the morons far outnumber us geniuses. It's our cross to bear.

Anyway, PHP is dead. Probably. Here's why.

## PHP is Stagnating

PHP 4 was released in May 2000. PHP 5 was released in July 2004. PHP 4.4 was released in July 2005. PHP 5.3 was released in June 2009.

These dates are not enumerated here to poke fun at the slow release cycle of PHP (I'll get to the core team later). Rather, it's to illustrate a point. Here are some numbers that I pulled from some random data dump from some non-English site that's probably totally legit:

SELECT
SUBSTRING(libelle, 1, 1) php version,
SUM(nombre) count
FROM stats
WHERE libelle REGEXP '^[3-6](\\.\\d(\\.\\d)?)?$' AND date LIKE '2008-10-06%' GROUP BY SUBSTRING(libelle, 1, 1) The results of this query are: php version count ----------- ------- 3 8096 4 2396211 5 1977067 6 23 If it's not abundantly clear to you unwashed masses what a "libelle" is, I'm pretty sure that's "label" in some kind of European language. The dataset represents a census documenting what technologies people use to power their sites. Basically, this query is saying that in October of 2008, 2.3 million people used PHP 4 on their website and 1.9 million people used PHP 5 on their web site. At that time, PHP 5 had been stable for 4 years, and PHP 4 had been stable for 8 years. Their usage in production is pretty much even. PHP 5 added a lot of features, such as, you know, object-oriented programming. And yet it takes ten years (and counting) for PEAR to get off their asses and convert their code to PHP 5. For those who don't know, PEAR is the PHP Extension Application Repository. It's a packaging mechanism similar to yum or apt-get, as well as a repository for extensions to the PHP language written in PHP (as opposed to PECL, which are extensions to the PHP language written in C). It defined a coding standard, and generally did a lot of good for the PHP community, except that it's written in freaking PHP 4, and the coding standard is embarrassingly terrible. For example, they prefix member variables with underscores to indicate that it's not public, since PHP 4 didn't have the notion of member variable accessibility. PHP 4 also didn't have the notion of static. You should see the way they implement the singleton pattern in PHP 4. It's pretty hilarious. PHP 4 also didn't pass objects by reference. That means you manually had to insert ampersands everywhere to make sure that your objects wouldn't be treated like a value type. And when I say everywhere, I mean everywhere. This is a very common occurrence in PHP 4: $myReferenceType =& new AwesomeClass();

DEAR GOD YOU COULDN'T EVEN USE THE NEW KEYWORD WITHOUT EXPLICITLY DEFINING THE REFERENCE. WHY ARE PEOPLE STILL USING THIS VERSION OF PHP?

This is all a long way of saying that PHP 4 is hideously outdated, both in calendar time and technologically, and yet it remains very prominent. I die a little inside when I see someone using a host that's rocking Apache 1.3 and PHP 4.3. It's like seeing someone using the cgi-bin directory. Aren't we past that yet? This isn't 1997 anymore.

The same argument goes for PHP 5.3 as well. It added some sorely missing features, such as namespaces and true anonmyous functions, as well as a plethora of classes in the SPL, and yet no one is upgrading. It's been a year, and people are still creating classes called Awesome_Controller_Abstract instead of using namespaces like a normal person. It's heartbreaking.

This is what will cause PHP to always be slightly behind the curve technologically: its users' snail's pace upgrade rate. Eventually, its one strength, the extremely low barrier to entry, will be nullified as other languages figure out how to be more accessible to the masses.

## The PHP Core team is separated from reality

So, I imagine this is a problem for a lot of languages, and I'm definitely making unfair blanket statements, but I want to bring it up for one very specific reason. Try to read the next sentence without laughing.

In PHP, the namespace separator is the backslash.

You laughed, didn't you?

Allow me to give a bit of backstory without citing any sources.

There was fairly raging debate among the core developers on what to use for the namespace separator in the months before PHP 5.3 was released. You see, it wasn't as simple as you might think, because PHP isn't primarily an object-oriented language.

The original solution was to use the paamayim nekudotayim (scope resolution operator, but the Hebrew version is way cooler) as a namespace separator. But oh no! That caused problems in situations like this:

//bar.php
namespace Bar;

function foo() {}

//meanwhile, in baz.php
require_once bar.php;

class Bar {
static function foo() {}
}

Bar::foo(); //which foo gets called? in the Bar namespace or in the Bar class?
So, the core team realized they had a problem. There were several solutions:
1. Only apply namespaces to OO code (classes, interfaces, etc.)
2. Change the namespace separator character to something unambiguous

Hindsight is always 20/20, but the second option there seems pretty retarded to me. It's hard to find an unambiguous character in any language that has previous releases, because they're all being used. What happens is you'll end up choosing a character that's hard to type (i.e. one you have to press shift for), or you'll choose something that's unambiguous technically (meaning not significantly used) but has ambiguous semantics (like, say, the escape character in every language besides T-SQL).

At one point, the core team actually created a matrix where each row was a different character (I think the triple colon was in the running at one point, which would probably be even more awesome when translated to Hebrew), and each column had funny stuff like "is hard to type" with a numeric value. The last column summed up the numeric values and the row with the highest number was the winner. It was all very democratic (THROUGH PURPLE MOUNTAIN MAJESTIES...).

The backslash won.

Well, kind of. Pretty much everybody who typed code for a living hated the backslash because, you know, IT'S THE BACKSLASH. Nobody wants to look at that.

But PHP is an open source project, which means most or all of them don't get paid to work on it, so that means that the easiest solution will win. And in this case, the easiest solution was the one that was already done. One of the core developers got tired of the bickering and the matrices and the Hebrew and he spent a weekend implementing the backslash namespace separator and committed it to the branch. Then he wrote tests covering all possible cases, and created a patch against trunk.

He had everyone at "tests" and "patch". And that's how the backslash became the namespace separator for PHP.

This was all a a long way of saying their decision was made with their brains instead of their guts. If they used their guts, they would have realized that NOBODY GIVES A CRAP ABOUT NAMESPACES EXCEPT PEOPLE WHO DO OBJECT-ORIENTED CODE. Nobody cares if the 4000 lines of random functions in stuff.php is in a namespace. The only people who care about namespaces are those that experienced it in another language (like say, an object-oriented language) and would want to apply the same organizational structure to their PHP code. And those people are only writing classes and interfaces.

Ergo, they should have ignored the collision issues illustrated above, only applied namespaces to classes and interfaces, and rocked the PAAMAYIM NEKUDOTAYIM like it was going out of style. But since the PHP core team are experts in C, not PHP, they didn't really realize this.

Instead, we are condemned to a life full of backslashes. I've already started a support group.

## PHP 6 is a disaster area

I don't have a lot to say about this, except that it seems like it's an absolute disaster. The main thing going on in PHP 6 is unicode support.

yay.

I'm not totally sure why that's so awesome, but it's a lot of work, and it isn't going well. Again I'm not going to cite any sources, but it's been in the works for about two years to add unicode support to PHP, and I don't think it's very close to being done.

The problem seems to be that they can't just add unicode support, because every extension would be incompatible. So they're trying to retroactively add unicode support to everything at once, which is as terrible as it sounds. I could be making all this up, but it sounds similar to something I might have read once.

Basically, they're attempting to add a feature that will be of minimal value, and it's taking forever. Instead, they could be adding cool things, like some of these:

## In Conclusion

PHP is dying. Probably. I hope I'm wrong, because I think PHP is a very expressive, convenient language. It has, by far, the best function library of any language. It also has, by far, the best documentation of any language, as well as a giant, open community around it. For those reasons, I hope it doesn't die. But I've seen little evidence that it's not going to march straight to hell.