3 ms·
Well, here is a paper you may find useful: https://days2011.scala-lang.org/sites/days2011/files/ws3-1-Hundt.pdf https://days2011.scala-lang.org/sites/days2011/
by sievebrain 10y ago
Well, here is a paper you may find useful:
https://days2011.scala-lang.org/sites/days2011/files/ws3-1-Hundt.pdf https://days2011.scala-lang.org/sites/days2011/files/ws3-1-H...
They write the same program in C++, Java, Scala and Go, then compare performance both before and after optimisation.
They key part that shows Java can be as fast as C++ is V.E "Java tunings":
Jeremy Manson brought the performance of Java on par
with the original C++ version. This version is kept in the
java_pro directory. Note that Jeremy deliberately refused
to optimize the code further, many of the C++ optimizations
would apply to the Java version as well.
The tunings he applied are not exotic, but would not be used in most code unless it was actually performance sensitive. For instance he chose better starting sizes in ArrayLists and replaced boxing collections with more optimal ones (presumably from GNU Trove).
Of course, that is a comparison against the original C++. Later in the paper it is shown that Google were able to optimize the C++ version heavily and it then beat the Java version again, however, apparently the optimised version relied on data structures so exotic that they're Google proprietary and they chose not to open source them, so I'm not sure that'd be reflective of the experience of the average C++ developer.