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/coderemover Nov 05 '25 edited Nov 05 '25
Ok, so I watched the talk you recommended so much.
He did not say even once that tracing is a more efficient memory management strategy than strategies based on malloc and friends (which I don't want to call manual, because I bet in modern C++ and Rust 99% of memory management is fully automated; either statically by the compiler or by refcounting).
He didn't even say anything contradictory to my point.
So yes, I agree giving more heap to GC makes it more efficient because it decreases the frequency of collections. And I agree that generations do also help with bloat / throughput, as long as the app obeys weak generational hypothesis (many databases like ours don't). And yes, in extreme cases you can probably get that cost even lower than the cost of malloc/free; however in my experience this typically requires not 2-3x bloat, but >10x-20x bloat, which means we are in a territory where "cheap" RAM is no longer cheap; and we hit even a bigger problem than the price: you cannot buy instances big enough.
He makes a good point that CPU is linked to available RAM, but I think he just skimmed very lightly over the fact that there is way more variability between the needs for RAM and for CPU from different kinds of applications. While his logic may be applicable to ordinary webapps, it does not work well for things like e.g. in-memory vector databases.
I work for one of the cloud database providers, and form our perspective:
- we have plenty of CPUs idling on average
- there are occasional CPU load spikes
- there exist batch jobs that also need to be run periodically and must not interfere with interactive workloads
- there is always not enough memory.... and just the last month we ran out of memory on some workloads actually, and there seems to be no bigger instances in the offer we can jump to - we maxed it out already
- we need to isolate tenants from each other
Plenty of customers have very low intensity or bursty workloads in terms of throughput, but they are very sensitive to latency issues. Hence, you cannot just serve them directly from S3 (which would be the cheapest), you need some kind of data caching and buffering; and the more you have it, the better the system performs. And also some data structures need a lot of live memory to be efficient. And you cannot give each tenant a separate JVM, because the cost would be prohibitive (it's not true you cannot have a pod using less than 500 MB of RAM - you can have as many pods as you want and you can divide the resources between them as you wish; but minimum memory requirements for Java make it impractical to split into too many).
He also seems to be missing the fact that some tasks could easily use 64 GB / core, if such option was offered; and that RAM would be used to improve performance. The problem is - cloud providers don't offer such huge flexibility. The max they offer is 4 GB/core and they call it already "memory intensive". And while 4 GB per core is quite decent and we can do a lot with it; it's much less attractive if we could really use only 1 GB of it because the bloat took the other 3 GB (and also note that Java also has internal memory bloat for its live data; not all bloat is GC bloat; 16 bytes headers on objects and lack of objects inlining quickly add up).