https://www.forbes.com/sites/quora/2015/05/26/when-is-java-faster-than-c/?sh=2d36dde53100Here's what I've learned over 20 years of working with both C++ and Java (and more years before that with C++):
As a rule of thumb, when you convert optimized C++ to Java, the code is about
3x slower.
As a rule of thumb, when you convert Java to C++, the code is about
3x slower. This doesn't make sense at first, until you consider that code written in Java is "tuned to" the way Java code tends to be written, which is not at all how anyone who works in C++ would structure C++ code.
Concurrent data structures tend to be more efficient in Java, because the JVM can eliminate the memory barriers and synchronization when the data structure is not being used concurrently, and can bias the concurrency management approach based on runtime profiling information.
Dynamic memory management tends to be more efficient in Java, particularly the more it is abused, and particularly in multi-threaded systems.
Inlining tends to be much better in Java, unless you do extensive profiler-based optimizations in C++ (or know what exactly to inline and force it to be so ... gotta love those header files!)
Large projects tend to be easier to optimize in Java, because the JVM handles many of the "global" optimizations (such as the ability to inline dynamically-loaded code) for the developer.