PHP is not Python is not Java

PHP is not Python is not Java.

Just back from Bali. Very nice vacation, thank you. Time for a little more speculation:

PJE has written two excellent articles Python is not Java and Java is not Python either.
Being a busybody, I thought I'd chip in by saying PHP is not Python either.

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.

  • Both Java and Python make it easy to distribute compiled apps in the default release.

  • PHP is not suitable for numerically intensive work. This is because
    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
    defined, which makes implementing a JIT compiler such as Python's Psyco
    much easier.

  • PHP's design decisions make it skewed towards web stuff. 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.

[PHP Everywhere – By John Lim]

Leave a comment