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

前端 未结 13 1661
不知归路
不知归路 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:56

    Some points to take into account:

    • If you get a better C++ compiler, your code doesn't become faster. You need to recompile it first. If you get a better JVM, all your Java code will run faster

    • If you get a better C++ compiler/JVM, you will see 10-20% faster execution, usually in corner cases. If you find a better algorithm to achieve what you need, you can easily get 1,000%-10,000% more performance, sometimes even more.

    So today, if performance is an issue, you should look at these two facts:

    • How easy does the language make it to replace one algorithm with another? (a.k.a "Refactoring")
    • How fast can you write code in it?

    Anything else is just FUD.

提交回复
热议问题