Under what circumstances is Java faster than C ++?
Reviewer: Cameron Purdy, Senior Oracle middleware engineer.
This is based on what I learned more than 20 years after using C ++ and Java at the same time. In fact, using Java is a few years earlier than C ++:
1. Based on my experience, when you convert the optimized C ++ code into Java code, the code speed will be about three times slower.
2. Based on my experience, the speed of converting Java code into C ++ code is also three times slower. First of all, this comparison is meaningless unless you are aware of writing Java code in Java, rather than organizing C ++ code like the C ++ developer.
3. It is more efficient to use Java for concurrent data structures. When the data structure is not used concurrently, JVM eliminates the memory barrier and synchronization, and tends to use concurrent management based on runtime performance analysis.
4. Dynamic Memory Management in Java is often more efficient, especially in systems with excessive use of dynamic memory management and multithreading.
5. Java Inline code often performs better, unless you have performed a lot of Optimization on C ++ code based on analyzer or know exactly how to use inline to make C ++ more efficient ...... You will definitely fall in love with these header files !).
6. Large projects using Java are often easier to optimize, because JVM has made many "Global" optimizations for developers, such as inline dynamic loading of code capabilities ).
At least I feel like this ......