r/cpp • u/drakgoku • Oct 31 '25
Java developers always said that Java was on par with C++.
Now I see discussions like this: https://www.reddit.com/r/java/comments/1ol56lc/has_java_suddenly_caught_up_with_c_in_speed/
Is what is said about Java true compared to C++?
What do those who work at a lower level and those who work in business or gaming environments think?
What do you think?
And where does Rust fit into all this?
25
Upvotes
3
u/eXl5eQ Nov 01 '25 edited Nov 01 '25
Maybe because
Java heap allocator is A LOT faster.
No deallocation overhead. The garbage collector well handle that in background, as long as you have enough RAM. Java programs can easily consume 10x or 100x more memory than a C++ one.
Array copy is always a simple memcpy in Java. No constructor overhead.
No destructor overhead.
ensureCapacity()is a very high-level operation. I don't think JIT will mess with that.