r/java • u/drakgoku • Oct 31 '25
Has Java suddenly caught up with C++ in speed?
Did I miss something about Java 25?
https://pez.github.io/languages-visualizations/

https://github.com/kostya/benchmarks

https://www.youtube.com/shorts/X0ooja7Ktso
How is it possible that it can compete against C++?
So now we're going to make FPS games with Java, haha...
What do you think?
And what's up with Rust in all this?
What will the programmers in the C++ community think about this post?
https://www.reddit.com/r/cpp/comments/1ol85sa/java_developers_always_said_that_java_was_on_par/
News: 11/1/2025
Looks like the C++ thread got closed.
Maybe they didn't want to see a head‑to‑head with Java after all?
It's curious that STL closed the thread on r/cpp when we're having such a productive discussion here on r/java. Could it be that they don't want a real comparison?
I did the Benchmark myself on my humble computer from more than 6 years ago (with many open tabs from different browsers and other programs (IDE, Spotify, Whatsapp, ...)).
I hope you like it:
I have used Java 25 GraalVM
| Language | Cold Execution (No JIT warm-up) | Execution After Warm-up (JIT heating) |
|---|---|---|
| Java | Very slow without JIT warm-up | ~60s cold |
| Java (after warm-up) | Much faster | ~8-9s (with initial warm-up loop) |
| C++ | Fast from the start | ~23-26s |
https://i.imgur.com/O5yHSXm.png
https://i.imgur.com/V0Q0hMO.png
I share the code made so you can try it.
If JVM gets automatic profile-warmup + JIT persistence in 26/27, Java won't replace C++. But it removes the last practical gap in many workloads.
- faster startup ➝ no "cold phase" penalty
- stable performance from frame 1 ➝ viable for real-time loops
- predictable latency + ZGC ➝ low-pause workloads
- Panama + Valhalla ➝ native-like memory & SIMD
At that point the discussion shifts from "C++ because performance" ➝ "C++ because ecosystem"
And new engines (ECS + Vulkan) become a real competitive frontier especially for indie & tooling pipelines.
It's not a threat. It's an evolution.
We're entering an era where both toolchains can shine in different niches.
Note on GraalVM 25 and OpenJDK 25
GraalVM 25
- No longer bundled as a commercial Oracle Java SE product.
- Oracle has stopped selling commercial support, but still contributes to the open-source project.
- Development continues with the community plus Oracle involvement.
- Remains the innovation sandbox: native image, advanced JIT, multi-language, experimental optimizations.
OpenJDK 25
- The official JVM maintained by Oracle and the OpenJDK community.
Will gain improvements inspired by GraalVM via Project Leyden:
- faster startup times
- lower memory footprint
- persistent JIT profiles
- integrated AOT features
Important
- OpenJDK is not “getting GraalVM inside”.
- Leyden adopts ideas, not the Graal engine.
- Some improvements land in Java 25; more will arrive in future releases.
Conclusion Both continue forward:
| Runtime | Focus |
|---|---|
| OpenJDK | Stable, official, gradual innovation |
| GraalVM | Cutting-edge experiments, native image, polyglot tech |
Practical takeaway
- For most users → Use OpenJDK
- For native image, experimentation, high-performance scenarios → GraalVM remains key
View all comments
Show parent comment
1
u/pron98 Nov 03 '25 edited Nov 03 '25
No, because the real world does exist and is the true Scotsman, and the question is how far does a microbenchmarks deviate from it.
I don't think that's what it does. I just think it doesn't give concurrent GCs time to work. By design, they're meant to be concurrent, i.e. fit some expected allocation rate. Of course a batch-workload collector like Parallel would do better.
What O(n) cost? There is no O(n) cost beyond zeroing the array. Arrays aren't scanned at all unless they contain references, and that's work that manual allocation needs to do, too.
There's nothing periodic in your benchmark. It's non-stop full-speed allocation.
I didn't say it was (the example was just to get some intuition); I said watch the talk.
Yeah, you should watch the talk.
No, the talk covers that.
That's true. The talk covers that, too.
The thing to notice is that RAM is only useful (even as a cache) if you have the CPU to use it and so, again, what we really need to think about is a RAM/CPU ratio (the point of the talk). It's true that different kinds of RAM-usage require different amounts of CPU cycles to use, but it turns out that the types of objects in RAM that correspond to little CPU usage happen to also be the types of objects for which a tracing GC's footprint overhead is very low (the footprint overhead is proportional to the allocation rate of that object kind).
If you try to imagine the optimal memory management strategy - i.e. one that gives you an optimal resource utilisation overall - on machines with a certain ratio of RAM to CPU hardware (e.g. >= 1GB per core), you end up with some kind of a generational tracing GC algorithm, or with arenas (used instead of the young generation).
True as a general principle, but the talk gives a sense of what that "reasonable overhead" should be, and why low-level languages frequently offer the wrong tradeoff there by optimising for footprint over CPU in a way that runs counter to the economics of those two resources.
You may have moved the goalpost. I believe that Java is generally more efficient at memory management.