Python vs PHP

Cliff Wells clifford.wells at comcast.net
Fri Oct 22 06:56:44 EDT 2004


On Thu, 2004-10-21 at 23:03 -0700, Shufen wrote:
> Hi all, 
> 
> 
> 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.

PHP and Python are both very dynamic languages.  I've used both pretty
heavily (although Python far more) and I'll make these observations:

On paper, PHP is pretty good.  In real life, the interpreter is badly
broken in many ways.  Much of this is supposedly fixed in PHP5 with the
new Zend engine, but that remains to be seen.  The object model in PHP4
barely works.  It doesn't support chained references (i.e. a->b->c
doesn't work) or doing things like utilizing the return value of an
expression or function call unless it's been assigned to a temporary
variable (i.e. a function foo() returning an array can't be used thusly
foo()[0].  Whether or not this is a bad thing is arguable, I'm merely
demonstrating the language's lack of a feature, or rather, lack of
generality).

PHP has some excellent libraries for web development.  In many ways this
makes up for the shortcomings in the language itself, since you can
quite often keep actual programming to a minumum.  I've seen nothing in
the Python world that compares to Smarty templates (and yes, I've
reviewed the many Python templating engines available.  To date I've
seen none that approach Smarty in actual
usability/readability/simplicity).

Outside of web development PHP makes little sense.  One of the silliest
abominations I've ever encountered is PL/PHP, a procedural language for
PostgreSQL.  The only thing arguably worse is PL/Perl. (Note: Luckily we
have PL/Python available <wink>).

Python, on the other hand, is a remarkable general purpose language (of
course you shouldn't be surprised to hear that here).  If PHP is the
best language for the web (due to its tight integration with the server
and its specialized libaries), then Python is the best language for
everything else, and a close second for best language for the web (and
I'm sure you'll hear arguments that it's the best in that category as
well).  

If you are strictly doing web development and are familiar with PHP,
then I feel you have nothing to lose (aside from gaining some broader
experience) with sticking with PHP.  If you plan to do anything else,
don't even consider it.  Use Python or some other general-purpose
language.

Regards,
Cliff

-- 
Cliff Wells <clifford.wells at comcast.net>




More information about the Python-list mailing list