As much as I usually like John Lim's excellent PHP Everywhere, I don't particularly agree with his comments on Ian Bicking's Why Web Programming Matters Most. Being a longtime PHP programmer (since when it was called PHP/FI) and PEAR contributor, and having heavily used (and loved) Python for all my projects in the past couple of years, both Ian's
resolving Python's problems with web programming is the most important thing we can do to market Pythonand John's
what made PHP successful is not what PHP is lacking but the features that PHP has that are superior to Pythonring true to my experience.
What I don't particularly agree with is John's list of things PHP "does better" than Python:
- Python is not a template language. Even though the "templating" nature of PHP makes it easy to use for casual programming, it soon becomes a real PITA even for smaller applications
- Python is a so-so string processing language. Python is a much better string processing language. I find
'abcd'[:2]
much more readable thansubstr('abcd', 0, 2)
, and"aaa%saaa" % var
much cleaner and less error prone than"aaa${var}aaa"
. The list could go on with triple quotes, raw strings, Unicode support, etc. In fact, Python's string processing is one of the many things I miss in PHP. - PHP's documentation is cleaner and much easier to understand than Python's. I don't think PHP's documentation, or PHP itself, are "cleaner" than Python. Just compare the myriad of array functions in PHP with the mapping methods in Python, which fit in a single HTML page. With PHP documentation, you often have to resort to reader's comment to understand a function's behaviour, something which (almost) never happens with Python's docs. My understanding is that people are intimidated by the number of libraries included with Python, and never take the time to learn the basics of the most important ones, thus missing the key section of the docs. And it also seems that nobody knows there's the PQR around.
- PHP has tighter integration of a lot of web related stuff. Even though PHP's _ vars (_REQUEST, _SERVER, etc.) variables are very useful, I don't see much difference in having them available as eg a request object's attributes.
In all other respects, Python beats PHP hands down: code quality and functionalities available in the included libraries, design cleanliness, unified DB API, namespaces, proper types, the list could go on for half a page.