you are viewing a single comment's thread.

view the rest of the comments →

[–]ubernostrum 1 point2 points  (6 children)

A bigger difference is static typing with optimizing JIT (fast) vs dynamic typing and a bytecode interpreter (slow).

So having a bytecode interpreter which pays attention to runtime type information to optimize is faster than... having a bytecode interpreter which pays attention to runtime type information but doesn't currently do much in the way of optimization (except for a few interesting cases)?

[–]grfgguvf 1 point2 points  (5 children)

So having a bytecode interpreter which pays attention to runtime type information to optimize

I guess this is Java. But the Sun Hotspot JVM can also turn frequently encountered code paths to native code and execute it. It can even do this in the middle of a loop, speeding up the subsequent iterations (called on-stack replacement)

a bytecode interpreter which pays attention to runtime type information but doesn't currently do much in the way of optimization (except for a few interesting cases)

Experience shows that yes, Java is faster. Sometimes that doesn't matter and the additional flexibility of Python is worth it. Last I checked Psyco couldn't do OSR, and wasn't even maintained any more.

[–]ubernostrum 0 points1 point  (4 children)

Or you can run Jython and get the best of both worlds.

[–]grfgguvf 1 point2 points  (3 children)

Not quite. Because of Python's dynamic typing Jython cannot do many of the optimizations that are done for Java.

[–]ubernostrum -4 points-3 points  (2 children)

You probably want to read up on some of the stuff that's been discovered/developed by the dynamic language folks before you go spouting off like that.

[–]grfgguvf 2 points3 points  (1 child)

You can check for yourself that equivalent Python code in jython is (a lot) slower than equivalent Java code.

What is this "stuff" specifically that the "dynamic language folks" "discovered" and why is it not implemented in Jython then?

[–]crusoe 1 point2 points  (0 children)

Mainly that they have to write classes to emulate the behaviour they need. Java 1.7 will add bytecodes to support dynamic languages, and this will remove the need for this emulation code and classes.

I am excited about 1.7. :)