Python vs PHP (& Java?)

jerry_spicklemire at jerry_spicklemire at
Wed Dec 27 10:32:31 EST 2000

 Ben Ocean observed:

> I’m an intermediate-level programmer that’s new to Python (via Zope)
> and I like it a lot. However, it appears to me that, while Python is
> a good replacement for Perl, it cannot replace much of the
> functionality of  PHP, which can be scripted into HTML (whereas
> Python, it appears, must be called). So, I have to wonder about the
> speed of Python vs. PHP for Internet-based applications. Python has
> the advantage of byte-code and compilation, but it’s server-side. PHP
> might not be as fast on the server, but it doesn’t have to make as
> many trips back and forth between server and  client. Plus, I’m
> curious as to why Python wasn’t written in such a way that it could
> be written directly into HTML documents like PHP.

One thing at a time:

 Python packages for embedding scripts in HTML -




Any of these will allow you to do PHP/ASP-ish things with Python. On
the other hand, you've already gotten to know Zope, to some degree,
which is more powerful by far for typical Web development, so I'm a
little confused.

It sounds like you may have a basic misunderstanding of the stateless
nature of HTTP. When a (non-Javascript) script is embedded in HTML, the
processing that it invokes actually happens at the server, before the
client ever knows what's up. That's why you see the results of the
script, rather than the original code, when you view the source of the
HTML page. So, whether a PHP script is called, or a Python script,
it's the server side pre-processor that does the work. Javascript is
(mostly) different, since it is interpretted by the client (browser
with Javascript interpretter embedded). The "mostly" qualifier refers
to the real, but unpopular, option of using server side Javascript.
Yes, you can do it, but if you're working server side anyway, why
choose a language as limiting as Javascript?

I haven't heard of any browsers with PHP interpretters embedded, or a
client side PHP plugin, and until such a beast exists, the fundamentals
are unavoidable. But that's not bad. Client side processing is fraught
with compatibility nightmares, and even Java couldn't make much headway
until it moved decisively toward the server side.

> On a similar subject, someone once informed me that Java was by far
> the best language for scripting communication programs over the
> Internet (like chat, IRC, etc.).

Java is pretty good, has lot's of mindshare, and third party support,
no denying any of that. The Network Effect plays into this scenario, in
that one can feel reasonably comfortable with a Java based system for
any of the above applications.

Still, there are many very easy to use Python modules for such
functions, and if you are truly scripting InterNet Communications,
you're dealing with standard protocols. It doesn't matter what language
either end is implemented in. Java based clients can talk to Python
based servers, and vice versa.

The real question is, if you know both Python and Java, which one will
you use when either one will work. I'm very happy to take the word of
all the former Java hackers on this list who sing Python's praises for
many important reasons, productivity, flexibility, and simplicity being
only the most obvious.

Sent via

More information about the Python-list mailing list