[ Content | View menu ]

PHP Insanity IX

Mark Mzyk | May 8, 2008

Recently, on Hacker News, this question was asked:

What do hackers think of PHP?

If you’re thinking about PHP, I suggest you read the comments.  You’ll notice there is a constant refrain:

You can use PHP, but you had better have discipline.

Sure, you can use PHP or any language, but of course you need discipline.  That isn’t unique to PHP.  It just has to be stressed more often with PHP, because PHP requires extra diligence.  You have to be disciplined in understanding the core language, because it is inconsistent.

Following that discipline, I needed to use the ternary operator today, but I, for whatever reason, always forget the syntax.  So I turned to Wikipedia.  Today I was a bit more curious than usual, and I started reading the rest of the article.

The final section is titled Inconsistency of Implementations.  It contains this text:

Due to an unfortunate error in the language grammar, the implementation of ?: in the PHP language uses the incorrect associativity when compared to other languages, and given a value of T for arg, the PHP equivalent of the above example would yield the value horse instead of train as one would expect. To avoid this, nested parenthesis are needed…

It’s clear that PHP has lots of these unfortunate errors.  PHP has lagged in fixing them, and I think it has been eclipsed by the likes of Ruby and Python.  As these languages gain traction, I think PHP will slowly fade away.

It will take awhile, certainly.  PHP has an advantage in how easy it is to set up and get a page running, but that only gets it so far.  To fix all the errors and inconsistencies of PHP would be a full time job.  I’m not sure it can be done, unless PHP committed to a rewrite and broke backwards compatibility, but that’s a catch-22.  While PHP fixes itself, the other languages take over its share.  But if PHP doesn’t fix itself, the other languages still take over its share.

It doesn’t look good for PHP.

Filed in: Languages.