Why we’re stuck with PHP

The language of the masses?

Amber Yust
4 min readDec 17, 2013

In Silicon Valley, PHP is a running gag. It’s the language everyone uses as the butt of their jokes, or when they need a $TERRIBLE_LANGUAGE with which to demonstrate their superiority through non-usage. On some level, there’s a reason for this. PHP has been around for a while, so older versions didn’t have the benefit of learning from as many previous languages’ mistakes and newer versions are slower to be adopted, leading to the vast majority of PHP code being written against a more crufty API than the average language.

While newer versions of PHP are slowly starting to correct many of the mistakes that previous versions made (e.g. replacing the mysql_ functions with PDO/mysqli), backwards compatibility means that a lot of that crufty old functionality is still around where it continues to be used by those who simply don’t know better. Due to PHP’s age and its relative numerical popularity, there’s a large mass of mediocre information that refers to the older ways of doing things. The majority of first-page results for “using mysql with php” still refer to the deprecated functions, and the vast majority of open-source code still uses them. This isn’t going to change any time soon—there’s just too much momentum involved.

It might sound like a simple solution to simply have everyone start using a different language for web development. Unfortunately, there really aren’t any other languages that fill the exact same niche that PHP does. Any potential replacement for PHP would have to have the following qualities:

  1. A large community — part of why PHP is so popular is that there are many people who know the language and can answer questions about it, making it much more friendly to newcomers.
  2. Ease of transition from HTML — another reason why PHP is popular is that it doesn’t rely on frameworks to handle generate webpages. An existing webpage can be made dynamic by adding small pieces of PHP code, rather than overhauling the entire way the page is served.
  3. Ease of deployment — deploying PHP code is as simple as it gets: put a PHP file on a shared host. Pretty much every shared host nowadays supports PHP, and most people just getting into web programming already have a shared hosting account because they’re transitioning from static webpages. The deployment method for PHP feels natural to them.

There are plenty of languages that meet the first of these three criteria. There are far fewer that meet other two. Most “modern” web development is based on application/framework models (e.g. Rails, Django, Node), all of which completely fail both #2 and #3. While deployment is becoming easier with services like Heroku or dotCloud, it still requires far more setup than the simple “copy a code file into a directory” deployment model used by PHP. That’s not saying that PHP’s deployment model is better—only that it’s easy.

Easy is really what it’s about. PHP has the lowest barrier-to-entry of any web development language out there, and as such it becomes the starting place for the vast majority of self-taught web developers. Even if some of those developers eventually move on to other languages, many don’t — especially the ones that don’t become full-time programmers.

If none of the more modern languages can replace PHP, why not create a new language that can? The reality is that such a task is nearly impossible due to the chicken-and-egg problem created by hosting providers. PHP’s code and deployment model only works if the host supports it, since it relies on the web server to recognized PHP files and execute them properly. Shared hosts’ universal support for PHP is mostly due to it having become a standard feature—people expect hosts to support PHP and will shop somewhere else if they don’t.

Any new language would lack the benefit of already being standard, and thus face a significant uphill battle for adoption by shared hosting providers. Any language not supported by the majority of hosting providers would face a significant uphill battle for adoption by developers, in turn making it even harder to convince hosting providers that it’s worth making available. A language without significant adoption by developers is unlikely to have a large community, thus making it even less attractive.

PHP avoided adoption problems by simply being one of the first options in the space. PHP’s only real competitors when it first came out were scripts run through the CGI interface. For novice users, PHP was an easy choice — the ability to embed it in existing HTML was a killer feature for a new user. As such, it became somewhat of a standard for small-scale websites and naturally businesses targeted at small scale websites (shared hosts) picked it up as part of their core offering.

At this point, PHP is simply too entrenched as the “entry-level” web development language to be easily replaced. The only real ways to force a change would involve either (a) getting a large number of shared hosts on board with a new language proposal, or (b) starting a competing hosting service for the new language that offered deals too good to resist. The former is unlikely given how much fragmentation there is in the shared hosting space, and the latter is likely impossible to do while staying profitable given how competitive hosting prices already are.

“In software systems it is often the early bird that makes the worm.” — Alan Perlis

--

--

Amber Yust

Privacy Engineering & Manager @Google. EVELink maintainer, Guild Wars NPC, etc. My opinions and comments do not necessarily reflect those of my employer.