when is java faster than c++ (or when is JIT faster then precompiled)?

Posted by kostja on Stack Overflow See other posts from Stack Overflow or by kostja
Published on 2010-12-23T07:48:13Z Indexed on 2010/12/23 7:54 UTC
Read the original article Hit count: 272

Filed under:
|
|
|
|

I have heard that under certain circumstances, Java programs or rather parts of java programs are able to be executed faster than the "same" code in C++ (or other precompiled code) due to JIT optimizations. This is due to the compiler being able to determine the scope of some variables, avoid some conditionals and pull similar tricks at runtime.

Could you give an (or better - some) example, where this applies? And maybe outline the exact conditions under which the compiler is able to optimize the bytecode beyond what is possible with precompiled code?

NOTE : This question is not about comparing Java to C++. Its about the possibilities of JIT compiling. Please no flaming. I am also not aware of any duplicates. Please point them out if you are.

© Stack Overflow or respective owner

Related posts about java

Related posts about Performance