3 ms·
There are at least two reasons I can think of why a JIT language with GC can outperform C/c++: 1. Memory management with a GC often has higher throughput. With
by thayne 3y ago
There are at least two reasons I can think of why a JIT language with GC can outperform C/c++:
1. Memory management with a GC often has higher throughput. With the downside that you can have high latency when a garbage collection occurs.
2. The JIT compilation can potentially do a better job of optimizing, because it has information about how the code has been run so far.
It is possible for c or c++ (or rust) to get get the first using alternative memory management strategies, and the second by hand optimizing, and/or using profile guided optimization.
- pjmlp 3y ago3. The runtime also supports C++, and one emits the same MSIL code sequence that the C++ compiler would generate. Which is why WASM isn't that great novelty for grey beards.
- monocasa 3y agoI've also seen GC reliant concurrent algorithms that would require a lot more synchronization to keep track of when to actually free an object. GCed languages can just forget about the object and rely on the GC later to figure out what threads have access to valid objects. C and C++ need to figure out if it's safe to free.