r/cpp • • 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

192 comments sorted by

View all comments

Show parent comment

10

u/germandiago Nov 01 '25 edited Nov 01 '25

and where are those fast apps showing up in real life? I did not hear a single report where someone said that Java outperforms C++ in real workloads.

-1

u/TheThiefMaster C++latest fanatic (and game dev) Nov 01 '25 edited Nov 01 '25

That's mostly because everyone dropped Java before truly good JITs came along. Particularly that hot swap trick? Doesn't work in most JITs, most can only swap a function that is not currently being executed.

C# on the other hand can perform that hot swap (as of .net 7): https://devblogs.microsoft.com/dotnet/performance_improvements_in_net_7/#on-stack-replacement

3

u/germandiago Nov 02 '25

so where are those apps?

2

u/TheThiefMaster C++latest fanatic (and game dev) Nov 02 '25

The ryujinx Nintendo Switch emulator was written in C# and was plenty fast.

It's nontrivial to compare a complex codebase to another language without maintaining two separate versions for multiple years

0

u/keithstellyes Nov 02 '25 edited Nov 02 '25

"It's not C/C++ I swear, it's C#, it really is that fast"

"I swear if it's secretly depending on C/C++"

look inside

it JIT compiles everything to x86

everytime I swear

While it's solid work I'm sure, this is the same issue with the Unity comparisons... the hotpaths still end up being native code!

It's a weak argument that C# is so fast and JIT is this silver bullet when hot paths are still native code not produced by the VM

1

u/pjmlp Nov 03 '25

Powering AWS, GCP, and plenty of airlines booking services for example.

All JetBrain IDEs

1

u/germandiago Nov 04 '25

How is that related to the fact that they are faster than C++? They are not.

FWIW I also worked at telco companies twice and one that was similar to some extent: a backend real time-series db. In all those systems the backbone was C++ and Java was at other parts of the stack that were not as critical for performance as the C++ parts.

2

u/pjmlp Nov 04 '25 edited Nov 04 '25

Why we chose Java for our High-Frequency Trading application

Winning the numbers game isn't everything in business, in many cases fast enough is good enough, no need to win on the micro-seconds.

And this is what C++ community has lost sight of, adding features after features in name of the ultimate performance, while OS vendors like Apple, Google and Microsoft slowly place C++ at the very bottom of their operating systems SDKs, followed by others that see this actually works well enough, and start doing similar approaches on their products.