The PHP Fractal
Support Ukraine

The PHP Fractal

The 90's: High school, Nirvana[a], Windows 95[b], and this thing called the Internet. Right in the middle of all that 26-year-old Rasmus Lerdorf[c] released his Personal Home Page Tools[d], which would later be named after its initials: "PHP[e]".

This blog has a search engine written in PHP[f][1], and this week I had the displeasure of trying to figure out why some blog entries weren't properly indexed. After a couple of hours I realized that PHP was by far not my favorite programming language, and I set out on Google to find some company for my misery. I did indeed find a lot: everything from the classic and much referenced PHP: a fractal of bad design[g], to an entire subreddit called LOLPHP[h] where people come to dunk on PHP. I also found many advocates of PHP, who insisted that the language was just fine - if you were just a "good enough" developer.

It was the typical religious war. Very 90's.

Having fond memories of that decade, of course I have to jump in. I think PHP is getting unfairly slagged, and I think most criticism of the language fails to get to the core of the problem. Take, for example, the beginning of PHP: a fractal of bad design:

I can't even say what's wrong with PHP, because- okay. Imagine you have uh, a toolbox. A set of tools. Looks okay, standard stuff in there.

You pull out a screwdriver, and you see it's one of those weird tri-headed things. Okay, well, that's not very useful to you, but you guess it comes in handy sometimes.


And on you go. Everything in the box is kind of weird and quirky, but maybe not enough to make it completely worthless. And there's no clear problem with the set as a whole; it still has all the tools.

That's what's wrong with PHP.

Evelyn Woods[i]

Because there is a clear problem with the whole set: it's old.

If you look at PHP's contemporaries, you'll find many of the exact same failings. If you judge PHP by the standards of 2022 it's horrible. It does a lot of things not just a little bit wrong, but dangerously wrong. But if you pit it against ASP[j], JSP[k], Perl[l] or early Python[m] - it's actually pretty good. Really, here's a scripting language that can be used by beginners, that can be deployed everywhere, and you just put a little <?php ... ?> in your webpage and you're off doing dynamic server pages. As for the failings: what language had, for example, good Unicode support in 1998?

The difference, a quarter-century later, is that PHP's contemporaries have either died (JSP, ASP, Perl)[n] or gone through the very painful and arduous process of modernizing the core of the language to incorporate the knowledge gained in that time (Python[o]).

Python did the 2-to-3 switch to (among other things) support Unicode, which today is an absolute necessity. It took them eleven years[2], but as a developer I can say that it was worth it. PHP still slogs along with strings-as-bytes and special multibyte-string functions, making something as basic as text handling a chore.

It's not impossible to do Unicode in PHP. It's just that it's as difficult as it was in the mid 90's. Other languages correctly identified this as something that must be made easy and then made it easy. You can say this about many things in PHP: not impossible, just 90's difficult. Just as we did write some great software in the 90's, you can write great software in PHP. But we've made it easier (and safer) since then.

Unfortunately, it's not just the language that has stayed behind. It's the attitudes as well. PHP still talks about that "good enough programmer" that never makes mistakes, without understanding what everyone else concluded as the 90's rolled over into the 00's: unless your language or runtime helps you, you don't just need to be good enough yourself, you need for everyone to be good enough programmers; and since this will never happen you better deal with it in the language, the compiler, or the runtime.

To summarize, I don't think PHP is bad. The 90's weren't bad. But PHP needs to evolve, or do like the 90's and become a thing of the past.