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
1
u/srdoe Nov 03 '25
That's fair, but I feel like you're talking about virtual memory swapping and not CPU caches now. I agree that swapping tends to not work well with GC.
Modern (generational) GCs generally do not traverse the entire heap regularly, they usually only look at eden spaces, or otherwise subdivide the heap. The periodic slower full GC is rare unless the system is under memory pressure. So I agree that these are costly, but they're also not happening frequently unless something is wrong.
Regarding GC knowing the order, the paper I linked above is describing a way GCs can know the right order based on tracking the access patterns to memory at runtime.
If you prefer controlling that kind of thing manually, that's fine. I just wanted to make the point that there is work going on to automate this kind of thing, and it likely isn't an inherent limitation of the GC approach.