Tag Archives: Performance

Java vs C++ Performance Comparison, JIT Compilers, Java Hotspot & C++ Native Compiler

Java vs C++

Java vs C++

The gap between Java vs C++ performance has been narrowing for the past years; studies (Y Nikishkov, G Nikishkov & Savchenko, 2003; Taboada et al. 2013; Lewis & Neumann 2013; Oracle n.d.; Oancea et al. 2011) have shown that Java can achieve similar performance to natively compiled languages such as C++. Taboada et al. (2013, p425) argue that thanks to the Just-in-Time (JIT) compiler of the Java Virtual Machine (JVM) Java obtains native performance from Java bytecode.

Just-In- Time (JIT) compiler can significantly speed up the execution of Java applications. The JIT, which is an integral part of the JVM takes the bytecodes and compile them into native code before execution. Since Java is a dynamic language, the JIT compiles methods on a method-by-method basis just before they are called. If the same method called many times or if the method contains loop with many repetitions the effect of re-execution of the native code can dramatically change the performance of Java code (Y Nikishkov & G Nikishkov & Savchenko 2003. p2402).

With JIT the compilation can be optimized to the targeted CPU and the operating system model where the application runs. The system is able to collect statistics about how the program is actually running in the environment it is in, and it can rearrange and recompile for optimum performance. Continue reading