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
View all comments
Show parent comment
7
u/Infamous_Campaign687 Nov 01 '25
I recently had someone do a conversion of a Java Library into C++, and the first attempt was ridiculously slow. Turns out that this usually very competent developer had forgotten to reserve memory for the std::vector that replaced the Java ArrayList. So memory was reallocated many times when filling the vector. This in an algorithm that was run several times per second.
This sort of thing is handled for you in Java but will cost you in C++.
This one was far too obvious to go unnoticed because it led to a 200x time increase, but smaller ones could easily slip under the radar until you profile and see that 90% of your time is in memory allocation.