Can anyone quantify performance differences between C++ and Java?

前端 未结 13 1684
不知归路
不知归路 2021-01-31 11:33

Java was initially slow before the JIT but today performance is pretty close to C++. I want to know if someone has done measurable performance comparisons between the two langu

13条回答
  •  星月不相逢
    2021-01-31 11:58

    I have implemented performance-sensitive applications (physical simulations, financial models) in both C and Java. The reality is that I've always got much larger gains in performance by changing the algorithms than by tweaking the implementation -- but the implementation also matters. As for now, my opinion is that Java is slower than C (I don't have that much experience with numerics in C++), but a lot can be gained by careful tweaking, and this tweaking is a lot easier in Java, since you don't have to deal with segmentation faults, double frees, etc. C++ occupies the middle ground here, as modern C++ techniques (smart pointers, templates, STL containers) offer both speed and relative safety of use.

提交回复
热议问题