Python as replacement for PHP?
do.not at spam.me
Tue Mar 2 06:21:59 CET 2004
Erik Johnson wrote:
CAUTION: I'm replying as a non-Python programmer.
> 1) I think Python is cool.
> 2) We can do system administration type scripts (currently
> implemented in Perl), web page generation (PHP), and (potentially)
> client-side applications (including GUI's that make socket and/or external
> HTTP requests) in one language.
You can do client-side apps in PHP too. Pass the -q option to the CGI
version or just use the CLI version.
GUI - PHP-GTK
Sockets - The socket extension or fsockopen() to treat it as a regular file.
> 3) Python's interactive interpreter makes it easy to try things out.
? Like the -r option?
> 4) PyUnit - we would like to develop a robust set of tests and be
> able to do regression testing. I'm not aware of a JUnit/PyUnit analog in
> PHP. Are you?
> 5) Python has better code support for complex native data types
> (e.g., tuples, dictionaries, sequences, etc. and being able to write these
> directly in a hierarchical structure rather than building them up piecewise
> with function calls and assignments as in PHP).
In PHP, all these things are essentially arrays and that works fine.
Even the PHP developers say that classes are just syntactic sugar for
associative arrays (that'll change in PHP 5, though). So PHP is
procedural; there's nothing wrong with that.
Not to sound like I hate everything which isn't PHP. It's just that PHP
does have a wide range of functionality and is moving toward
command-line/administration capabilities, and is quite easy to learn if
you know other C-like languages. But if you think that Python better
serves your purpose, then you should use it. Surely, it would be
possible to write a strtotime() implementation in Python; someone may
have already done so.
More information about the Python-list