Just back from Bali. Very nice vacation, thank you. Time for a little more speculation:
Now let's see: Python is a multi-purpose language, good enough to be used for number-crunching, as Pixar's main scripting language when making movies, as the foundation for an application server such as Zope, for powerful P2P software such as BitTorrent, etc. PHP cannot do most of this. In other words, though PHP is an excellent rapid application development language for web software, PHP is currently not a general purpose programming language. This doesn't mean that PHP cannot be a general purpose programming language in the future, but it just isn't ready. Here's why:
You cannot embed the PHP runtime engine into an existing application, making PHP your application's scripting language easily. You can in Python provided that you are a competent C programmer. Update: Within minutes of posting this article, Derick Rethans points out php-irssi. Update 17 Dec: George Schlossnagle points out that PHP has the embed SAPI. Sadly both ways of embeding the runtime engine are poorly documented, rendering them effectively useless except for the best hackers (though embed is covered in George's Advanced PHP book).
Both Java and Python make it easy to distribute compiled apps in the default release.
PHP is not suitable for numerically intensive work. There are two reasons for this.
(1) PHP's variables are not type-strict once initialized. In PHP, a variable once defined can morph from a string to an integer or float transparently and back again. It is very hard to optimize this well, particularly when complex math formulae are involved. In comparison, Python requires very strict type casts after a variable is first initialized, which makes implementing a JIT compiler such as Python's Psyco much easier.
(2) Update (15 Dec): The second issue is the lack of support for purely sequential arrays (PHP arrays are actually dictionaries). This means that the large numeric arrays typically used in number crunching have to be simulated with less efficient dictionaries.
- Lastly, PHP's design decisions make it skewed towards web stuff (register globals, magic quotes, <?php ?>, etc). All the other reasons I mentioned above I believe are fixable. This one is more tricky as it is partly a social issue.
Even though PHP is not Python, there are still some things I read in "Python is not Java" that I do think apply to PHP:
- XML is not the answer, though SimpleXML makes it more palatable.
- Getters and setters are evil in PHP too.
- Code duplication is quite often a necessary evil in Java, but not in PHP where create_function() and eval() are available.