Saturday, January 17, 2009

Why Hacker News Thinks PHP Won Something

This happened yesterday:



I found these headlines strange.



The obvious question, of course, is what PHP allegedly won. And I mean that in both senses: what was the contest, and what was the prize?

The next question is: did PHP really win?

The third question could be: why did PHP win? It could also be: why does Hacker News think it won?

Both blog posts say PHP won by becoming the dominant programming language on the Web. This means that the contest was to see which language would obtain the most users, and the prize was having more users than anybody else. Whether this means they really won or not depends on whether or not this idea has any validity.

Of course, the answer's no. If you program in the most popular programming language, your skill in that particular language is a commodity. If you program only in the most popular programming language, you have made yourself a commodity. A commodity can only compete on location and price, and location doesn't really get you much on the Internet. This means that only people with a poor understanding of economics program in PHP.

For years I hid the PHP experience on my resume and even lied in job interviews, saying I didn't know the language. In reality, I've used every version. I remember it well. Back then we all used Perl. I was writing CGI scripts in Perl before there were HTTP libraries. Back then we hand-coded our headers, and we liked it. We walked twelve miles uphill through the snow both ways, and we opened database connections with backticks, and we liked it. Why? Because we were primitives and we didn't know any better, that's why.



I'd like to call this a Hacker News smackdown, but it isn't. First, top of the list of links for one day is just a blip on the radar. Second, if I really couldn't stand Hacker News, I wouldn't read it. Third, it's not a smackdown because it's not a decisive defeat. It's a tie. PHP didn't win, because what it was (allegedly) aiming for was something bad to have. But PHP also did win, because it got what it was (allegedly) aiming for.

The blog posts Hacker News links to - which, honestly, would be unusually moronic even if this was not Hacker News but Reddit or Digg - ascribe PHP's "success" to either its community or its features. In fact, PHP's "success" came from a combination of lucky timing, and two design decsions: embedding code in a web page, and imitating Perl.

Compare Microsoft's market dominance in the early days of GUI desktop PCs with PHP's dominance in the early days of Web scripting. In either case, an inferior technology overcame a similar, superior technology, within an emerging category. When PHP emerged, everybody was already writing CGI scripts in Perl. PHP was similar enough to Perl that a Perl hacker could be up and running in 15 minutes, and it was easier to use, in one simple, important way: it was embedded in the Web page. You didn't need to code up headers; you didn't need separate files.

This was a tiny win, but it occurred in the context of an epochal, unprecedented, world-changing paradigm shift that created thousands of jobs and destroyed entire industries. These extraordinary historical conditions magnified PHP's advantage. If you could create Web scripts faster than the next company, in the period from 1994 to 1999, it meant the difference between driving a Honda and piloting a yacht.



People who wrote a ton of PHP in those years invested a great deal of their time in PHP. They now have PHP skills, and they've given the world frameworks and libraries. These silly blog posts, which everyone on Hacker News voted up, both claim that PHP is the language most used on the Web, and although I have no evidence confirming or refuting it, I'm willing to believe them. But the blogs go on to say that PHP's "advantage" comes from its language features or its community.

First of all, PHP has no advantage. I once got an e-mail from a recruiter where the recruiter had mistakenly forwarded private comments from his boss. It said they were looking for a Perl hacker who would work for less money because they would get to choose Perl. That's how these people think.

Market forces are not about Care Bears and hugs. If you clone a programmer, two programmers with the same brain, and you send one out to hack PHP, and you have the other one use a language where you can charge a reasonable amount of money, the PHP programmer will make less money with the exact same brain. If you love PHP, for some insane reason, you're making less money than you could make, because of your poor taste in languages and your naive assumptions about market forces. This is not an advantage. PHP could not have lost harder.



Second, PHP's advantage came from a tiny ease-of-use boost, in an era where A) Web programmers did everything by hand, and B) the world changed overnight. There are no lessons for language designers here. You might as well be reading tea leaves. World-changing paradigm shifts by definition do not occur in the same category twice. Before PHP vs. Perl, it was Microsoft vs. Apple. A hundred years ago it was Railroad A vs. Railroad B. It's not going to be languages twice, for the same reason it's never going to be railroads again. There's no point making any language-design decisions based on PHP's success story. The gains PHP got from these design decisions do not correlate to the wisdom of the decisions but to the epochal circumstances of the moment when the decisions happened.

The secret strategy behind PHP's "success" is to already be standing in the right place when the big ball of money falls out of the sky. That strategy works, but it's not scaleable.

So you have two blog posts, at number 1 and number 2, debating which irrelevant cargo-cult strategy will net you a historic, unrepeatable "advantage" and enable you to "achieve" a "goal" which would decrease your earnings and have you writing painful, ugly code.

Hacker News used to be too good for this kind of thing. So the question here is: what on earth is wrong with Hacker News? Why is its quality declining? Is the decline inevitable?

But I've already answered that.