Tag Archives: C++

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

Java vs C++ Memory Management Features Comparison

Java vs C++

Java vs C++

There exist great differences between Java vs C++ memory management. One of the strengths of the Java platform is that performs automatic memory management; thereby developers do not need to worry about the complexity of explicit memory management. On the other hand, C++ provides developers with control over memory allocation and de-allocation using pointers, which indicate the memory can be use more efficiently and that performance programs can be optimized. However, Sun Microsystem (2006, p3) states that this can lead to serious executions errors. As a result, a large proportion of developers time is often spend debugging and trying to correct such error. In addition, there is nothing that restrains C++ developers from accessing OS data, or even executable code that resides in the memory (Vivanco & Pizzi 2005, p241). Continue reading