Python vs. PHP (& Java?)

entropia entropiamax at jazzfree.com
Wed Dec 27 14:31:54 CET 2000


As an example of how easy is python compared to java, look at the diferences of
xml-rpc implementations:
The links can be find at: www.xmrpc.org
I think that using python for xmlrpc is more elegant:
In Java I should do something like this:
try
          {
                  Object[] numParam = new Object[1];
                  Long stateNum = new Long(24);
                  numParam[0] = stateNum;
                  RPCClient rpc = new RPCClient();
                  rpc.setServer("betty.userland.com");
                  rpc.setPort(80);
                  rpc.setProcedureName("examples.getStateName");
                  rpc.setParams(numParam);
                  String stateName = (String)rpc.executeRPC();
          }
          catch (RPCException ex)
          {
                  ex.printStackTrace();
          }

In Python:
import xmlrpclib
betty =
                      Server("http://betty.userland.com")
                      print betty.examples.getStateName(41)


Thomas Wouters escribió:

> On Tue, Dec 26, 2000 at 10:03:05PM -0800, Ben Ocean wrote:
>
> > 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.
>
> You don't need roundtrips with Python either, you just need to start it as a
> CGI script (which is some additional overhead, granted.) And note that there
> are several extentions (PSP, ASP and if-I-recall-correctly mod_snake for
> apache, and Zope's DTML) that allow embedding Python into HTML.
>
> As for why Python isn't PHP, well, because it isn't. Python is a fair bit
> older than PHP, and simply wasn't intended as an 'html-embedded-language'.
> It was intended as a proper, easy to learn, easy to read, efficient (from
> the programmers view) language, and not as a quick-and-dirty-hack to allow
> code inbetween HTML :) The WWW and HTML did exist, but were only just
> starting, when Python emerged.
>
> And then there's two other points. I do a reasonable amount of PHP, and I
> think it sucks :) I don't see a terribly good reason to mix HTML and script
> code, for one. It looks sexy but there isn't a real advantage, and it only
> serves to clutter the code, IMHO. And besides that I've been bitten by
> irregularities in PHP code way too often, like how you can pass environment
> variables to the html page which end up variables inside the script --
> that's been the cause of several huge security issues for me. So even if you
> really want to embed code into HTML, I'd go for Python (or even Perl!)
> rather than PHP.
>
> > 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.). How does Python compare? Your comments are appreciated.
>
> Well, not suprising (since this is a Python newsgroup/list, not a Java one)
> I don't agree. Python is easier to write and easier to read (and
> understand), and way easier to learn. Python is (supposedly :) slower than
> Java in execution, but especially in networked environments, where you spend
> most of your time waiting for the network anyway, you aren't going to notice
> that.
>
> And besides, Python is so easy, you can learn it pretty quickly (in a few
> hours if you're already a somewhat-experienced programmer) and I doubt
> you'll ever regret it. If anything, it'll be a good programming learning
> experience. And it's just a fraction of the time you'll spend learning Java
> :)
>
> --
> Thomas Wouters <thomas at xs4all.net>
>
> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
>
> --
> http://www.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list