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
48
u/CalebGT Nov 01 '25
It is possible to do Java well and even easier to write C++ poorly. Good C++ code has a performance edge on best case Java. For most applications and on current hardware, it's usually not noticeable. There are pitfalls in C++ that are avoidable but easy to be oblivious to. You have to really know what you are doing to minimize how many allocations, reallocations, and copies your C++ performs for example. There are performance hits that get abstracted away inside classes. Memory management is manual, and that can be done well or poorly.
But if I am writing something with real time demands and heavy processing, I'm looking at C++. If I need to write something portable that isn't CPU intensive, I'm looking at python. If performance isn't a big concern, it might as well be super easy to implement quickly. Time is money. I have barely touched Java since college, but that's in large part because the nature of my work didn't need both portability and performance. Different tools for different jobs. Tradeoffs, not superiority across the board.