I am starting work on what will be a rather large project involved in real-time trading (NOT high frequency, but intraday). I've been stumped on the decision to go with Python or Java, which boils down to runtime performance.<p>After doing lots of research, I have not been able to reach any kind of stable conclusion regarding the performance capabilities of these two languages.<p>From what I can tell, although Java memory footprint is larger, as well as taking longer to start, it seems that it performs faster than Python does. Although I have read about popular JIT compiler add-ons for python, such as PyPy, that rumor C-like speeds.<p>So I ask you hackers: which language is better suited for a large enterprise application? This is not a website, it is an application that provides presentation through a browser for private use.<p>Thank you for your insights.
Forgive me if I'm repeating things people already know, I figure <i>someone</i> will find this useful -<p>One could of course ask...
Python and Java on what platforms?<p>Python at this point is a language specification - it has a multitude of runtimes. Java is technically a language spec as well, it just happens to USUALLY be seen executing on it's "native" runtime (Sun's JVM).<p>CPython is what many people think of when they think "Python" but is by no means the only Python anymore. One could (and many do - I hedge my opinion as there are good things and bad things about the GIL) argue that CPython's achilles heel is the Global Interpreter Lock (GIL): <a href="http://wiki.python.org/moin/GlobalInterpreterLock" rel="nofollow">http://wiki.python.org/moin/GlobalInterpreterLock</a><p>The GIL prevents multiple threads from executing in CPython concurrently - what you actually get is a whole lot of context switching and it vastly limits your performance ceiling on multicore boxes.<p>However - there is Jython and IronPython. Neither suffers from the GIL limitations, and can take full advantage of concurrent threads and multiple cores.<p>Jython (<a href="http://jython.org/" rel="nofollow">http://jython.org/</a>) is a Python implementation on the JVM - it's had a few development lags and only currently implements the Python 2.5 spec as far as compatibility. It is however a 13 year old project and heavily used - IBM embeds it in a few of their application servers as I recall. You also get to take advantage of the multitude of existing Java libraries. I happen to think these days the best way to parse Excel files, for example, is Jython. Use Python, but take advantage of Apache's POI Java libraries to do it ;)<p>There is also IronPython (<a href="http://ironpython.net/" rel="nofollow">http://ironpython.net/</a>) of which I am admittedly enamored. IronPython is a project from Microsoft (who sponsors development and employs, last I checked, the core team) which implements Python in C# executing on the CLR. It also runs on Mono, and Silverlight - allowing you to run Python in the browser. See the Gestalt project (<a href="http://visitmix.com/labs/gestalt/faqs/" rel="nofollow">http://visitmix.com/labs/gestalt/faqs/</a>) for examples of using IronPython + Silverlight to replace Javascript for arbitrary browser scripting. IronPython has done a good job of keeping up with the Python spec and at the moment provides full 2.6.x compatibility.<p>For those who want to stick with a "C" Runtime there is also Stackless Python (<a href="http://www.stackless.com/" rel="nofollow">http://www.stackless.com/</a>) but beware, as I'm of the understanding that it diverges from CPython significantly, where Jython and IRonPython strive for full compatibility with CPython apart from native platform libraries (This may be incorrect, I'd appreciate if someone could correct me if this statement is in error). It does however avoid the GIL by using Green Threads & MicroThreads, and Stackless Python powers much of the core programming for the Eve Online MMO.<p>PyPy I <i>believe</i> can run on any runtime so this doesn't apply to it (It's python hosted in python so any runtime that can run python should be able to run PyPy).<p>Utilizing Jython or IronPython would provide you a GIL-free platform for concurrency, and because the code is compiled down to VM bytecode you get a lot of free JIT help as needed.<p>Given you're talking about trading, being able to execute multiple threads is probably a crucial feature. The performance profile of Python depends a LOT on what you need to do and how you deploy it.<p>For maintainability and sanity I'm hard pressed to recommend Java, but if you wanted to go that direction you may also want to evaluate Scala which provides a lot of scalability oriented functionality on the JVM. Syntactically it should appear very "familiar" to Java and Python developers... I find it to be a bit hybrid as far as common keywords between the two.
Why are you so concerned about speed? Do you know right now that you'll have difficulty meeting a performance target on reasonable hardware?<p>Depending on what you're doing, Python may very well be faster than Java. I've done a lot of work with NumPy and found it to be both faster and safer than third rate roll your own numeric libraries that so Java programmers like to write. I've also had good success with Pyrex/Cython.<p>Assuming that run time performance won't be the determinative factor, your decision will probably come down to libraries and aesthetics more than anything else. I'd go with Python since I think it would allow you to iterate faster, but that's a very subjective decision.
If you're worried about this, you should use Jython. It gives you access to the JVM optimizer (which is awesome) and all 10,000,000 existing java libs with interop.