Skip navigation.

Python never had a chance against PHP

Ian Bicking has a very interesting and excellent Python blog. In Why Web Programming Matters Most he talks about PHP and Python:

And Python could have been PHP. We could have seen that kind of growth. But we didn't, because there has been and continues to be a bunch of little things that make Python annoying to use and get started with for web programming. But it's not all over -- PHP 5 is barely catching up to Python's features from 10 years ago. There's a lot of room for a better language to take it's place.

I have used Python since 1997, even before I knew PHP. I smile when Ian says that PHP 5 is barely catching up with the 1995 version of Python. That's irrelevant because what made PHP successful is not what PHP is lacking but the features that PHP has that are superior to Python. Also people continue to confuse simplicity with deficiency.

Here are some of the areas where Python remains inferior, despite a 5-year headstart over PHP:

  • Python is not a template language, in the sense that you cannot mix code and html easily. PHP is a wonderfully flexible in this respect.

  • Python is a so-so string processing language. One reason being it treats strings as immutable. PHP has much better string processing facilities: embedded "$var in strings", mutable strings, auto-conversion of other data types to strings, output buffering, etc.

  • PHP's documentation is cleaner and much easier to understand than Python's. Probably because PHP is a simpler language.

  • PHP has tighter integration of a lot of web related stuff. For example, HTTP and SERVER variables.

Python's design is elegant and appeals to computer scientists (me too, I have a CS degree from Melbourne). PHP has a more pragmatic flavour that is probably appealing to web programmers. For example, in Python, $_GET and $_POST are implemented in libraries, and not within the language itself; the mentality of a computer scientist is to do things right, not provide shortcuts for the convenience of mere html hackers ;)

So overall, I think that Python will never be as successful as PHP for web programming. Conversely PHP is weaker for general purpose work. And I think that is the way Python will continue to grow fastest: as a general purpose programming language, competing with Fortran, Java, C# and C++.