[BangPypers] Tuples vs Lists, perfromance difference
anandology at gmail.com
Thu Dec 24 11:45:17 CET 2009
>> Nope. With JIT compilation, a JVM can actually beat C++
> This seems a controversial statement to make. I have seen this come up
> time and again at various blog posts all trying convince one thing
> over the other.
Even if the raw CPU speed of Java is slightly less than C++, it is
highly possible that the Java version runs faster compared to C++
version if a reasonably complex program if written both in C++ and
Java/JVM has some advantages.
* Since Java supports garbage collection, objects can be passed across
libraries without worrying about who should free it. Many times in
C++, unnecessary copies are made at library boundaries.
* JVM does memory compaction to avoid memory defragmentation. In C++,
you have to live with it. memory fragmentation might also mean more
cache misses and more page faults.
* It is possible that JVM can move objects around for better cache
accessibility. (I'm not sure if JVM does it, but it is certainly
More information about the BangPypers