Mqrius wrote:people usually saying something should be coded in C if you want it truly fast.
It should be kept in mind, though, that the main reason people say that is because Java has an unfair reputation of being slow. I think the main source of that reputation is purely historical, since Java was slow in the beginning (before it even had a JIT). I take every chance I get to try and correct that. :)
That's not to say that there isn't any point in saying that C is faster, though. While I'd argue it isn't true per se, it is true that the performance of a C program is easier to analyze than that of a Java program. In C, one can know almost for certain even what exact instructions the compiler is going to emit for every piece of code, while in Java, there's a lot of uncertainty. Will the compiler inline this particular method? How fast are the java.util collections in absolute terms? Can I count on this object being stack-allocated? And, not least, how will this scale on other JVMs than Sun's? Can I even count on them having a generational GC? (Dalvik, for example, apparently hasn't. :O)
Mqrius wrote:I'm placing bets on the Pypy project, from the developers of psyco (no longer maintained, sadly), which aims to be faster than C through a JIT compiler of course, as well as some other features I haven't quite taken the time to look into yet. They're doing pretty well, according to their own stats, but not all modules can be used with pypy out of the box yet. Their project is pretty massive though, but I hope they whip it up into a usable shape sometime soon.
That's extremely interesting. I had no idea that Pypy had a Jit.
While interesting, though, looking at those comparison charts does verify my suspicion that no dramatic speed gains are to be had. While a few examples (like Django) are impressively much faster, most of the examples aren't even twice as fast as CPython, and even those that are much faster aren't fast enough to offset Python's slowness to begin with.
To be honest, I'm not placing any bets at all in Python being even possible to compile to fast enough code to ever be a reasonable alternative to C, Java or Lisp -- except, possibly, in some very advanced global optimizer like Stalin. Such global optimizers do have the particular problem of removing the ability to load code dynamically at run-time, however. Without a proper type system, type declarations or static structure information about objects, I don't really see how Python could be reasonably optimizable. If anyone does succeed, I'd be extremely interested in knowing how they did it.
Granger wrote:My point is: in case you manage to use python in a way to have it behave hundreds of times slower than java you simply do something terribly wrong.
I must admit that I don't really see how you could claim this. In any program that is mainly CPU-bound, Python is always really slow, and while I haven't made any actual quantitative comparison, I would be surprised if the difference wasn't on the order of hundreds of times. The only way I could defend writing a program in Python where performance actually matters, is if I knew that it will be mainly I/O-bound anyway.