Performance of Java 1.6 vs C++?

前端 未结 8 956
天涯浪人
天涯浪人 2021-01-07 06:04

With Java 1.6 out can we say that performance of Java 1.6 is almost equivalent to C++ code or still there is lot to improve on performance front in Java compared to C++ ?

相关标签:
8条回答
  • 2021-01-07 06:24

    For most applications it is almost certainly possible to write a C++ program which performs considerably better than a program to achieve the same thing in java.

    However if the program isn't optimised for speed then java will likely be just as fast or faster because the compiler / JIT is able to make optimisations that a C++ environment can't.

    Basically if you are willing to spend considerable time understanding and coding for performance you can probably do a considerably better job in c++ eventually than you could in java but for the same amount of time and effort it is quite likely that java will "win".

    As usual though, algorithmic improvements tend to make as much if not more difference than the language.

    0 讨论(0)
  • 2021-01-07 06:30

    Debian likes to conduct benchmarks on this sort of thing. In their case, it appears that Java is about half as fast and consumes 2-18 times as much memory as C++.

    0 讨论(0)
提交回复
热议问题