Python vs PHP
Ian Bicking
ianb at colorstudy.com
Fri Oct 22 12:37:09 EDT 2004
Shufen wrote:
> Can someone who has use PHP before and know quite well about the
> language, tell me what are the stuffs that Python offers and PHP
> doesn't. A few examples will be nice. I know about the date format
> problem which PHP is having but I need more examples. Thank you for
> any help.
Well, in general I'd say Python is better than PHP at pretty much
everything but:
* Regularly available on commercial hosts
* Unified basis for web development (there's still a lot of MVC-like
frameworks built on PHP, but they share more in common than in Python)
* Always uses a multiprocess model that both protects against bugs (or
at least, your server stays up no matter how buggy your PHP app or
libraries), and not too inefficient (like CGI).
* Easy to install and administer PHP applications; there can be a lot of
nuisances when installing Python web applications, like sys.path etc.
When it comes to all the more general things, Python beats PHP on pretty
much everything. Python has a clear and general object model -- PHP is
just starting to add some more generic things to its object model, like
operator overloading, and computed attributes. It still falls way short
of even the earliest versions of Python. I'll only briefly mention the
amateurish object implementation that requires assigning intermediate
objects to variables; I don't even understand what hackery caused that
misfeature.
Python doesn't have references (except that everything is implicitly a
reference), which is 100% a feature -- references are a horrible idea.
PHP seems to be moving away from references in version 5 as well.
Everything in Python is call-by-reference.
Python has namespaces and good modularity.
Python doesn't muck up quoting. PHP's magic quotes are bizarre and
dangerous, IMHO. They were a way of making up for PHP's sloppiness in
other areas. It never folds things into the namespace like PHP --
again, PHP programmers are moving away from this.
Well, that's just a short list. Just about everything you can think of,
Python is arguably better than PHP. Except for the web programming
environments -- which have their benefits in Python, but it forces you
to make a lot of choices and compromises that would be better forgotten.
But we're finally making some progress in Python to fix that
situation. (Incidentally, I work full time doing Python web
programming, and I've done a fair amount of PHP programming in the past
as well.)
At the same time, there's still a lot of really good PHP applications,
which is a testament to the language. Any language where people can do
good work is a good language; and while PHP's advantages over Python
seem small, I think the evidence shows that they are quite significant.
--
Ian Bicking / ianb at colorstudy.com / http://blog.ianbicking.org
More information about the Python-list
mailing list