Quote:
> I have an an atypical Java vs. Python question. To summarize, here's our
> scenarios: 1) We license Java and embed what we get from Sun into our
> application 2) We embed Python into our application. The question is, which
> will execute faster for the equivalent code on the same machine?
> As a background, our project involves distributed automated manufacturing (see
> http://www.*-*-*.com/ ~msl/minifactory/newminfact.html if you are interested).
> We need an interpreted language primarily to script the programs for each agent
> in the factory, in which case execution time is not a real problem. We are
> also toying around with sending pieces of code between cooperating agents which
> will be run inside an agent A's control loop to predict agent B's state so that
> we can reduce how often agent B has to send agent A its state. In this
> situation, the code (probably 10-100 floating point operations) may have to run
> at 100Hz or more, in which case efficiency of execution becomes critical, since
> we don't want to bog down the whole processor just executing the state
> predictor.
> I'm fairly new to both Python and Java, but the unsupported statements I've
> seen have hinted that Java code executes faster than the equivalent Python
> code. Is this a fundamental fact due to Python's run-time dynamic typing
> vs. Java's static typing? Is this just true for the highly optimized and
> banged-on Java compilers you might find in Netscape or Explorer, or is it also
> true for the code that comes straight from Sun?
> Jay Gowdy
The short answer is:
It depends.
Java has static typing and on most platforms has a more optimized
byte code interpreter.
Both languages have "native" modules that are usually coded in C or C++.
If you're calling routines in those modules it's going to run fast.
( Python has some numerical matrix extensions for example. )
Python probably has more native modules than Java -- a lot of JDK
classes look to be coded IN Java. ( again -- this will vary with
the classes and libraries distributed with any particular VM )
In both, you have the option of writing your own native modules.
( But for both, this downgrades the ability to migrate code --
unless you use ActiveX or something, you need to install the
native modules 'manually' . )
Someone said that most of the best compiler hackers in the US have
been hired by various companies to work on Java: Java VM performance
has had about a 10 fold inprovement since the language has been
around, and it seems likely that it will get pretty close to C++
performance in the next couple of years.
Have you looked at Jim Hugunin's paper on the python.org website ?
It's possible to have "the best of both worlds" !
---| Department of Molecular Physiology and Biological Physics |---
---| University of {*filter*}ia Health Sciences Center |---
---| P.O. Box 10011 C{*filter*}tesville, VA 22906-0011 |---
All power corrupts and obsolete power corrupts obsoletely." - Ted Nelson