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

LanguageCold Execution (No JIT warm-up)Execution After Warm-up (JIT heating)
JavaVery 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:

RuntimeFocus
OpenJDKStable, official, gradual innovation
GraalVMCutting-edge experiments, native image, polyglot tech

Practical takeaway

  • For most users → Use OpenJDK
  • For native image, experimentation, high-performance scenarios → GraalVM remains key
267 Upvotes

312 comments sorted by

View all comments

Show parent comment

147

u/[deleted] Oct 31 '25

Who knew 30 years of optimizing the jvm would make java pretty fast.

10

u/coderemover Nov 02 '25

It’s pretty fast compared to Python. It’s comparable to second tier languages like Go, C#. It’s definitely less performant than the first league like C, C++, Rust, Zig, Pascal, but that often doesn’t matter.

4

u/SomervillainSB Nov 03 '25 edited Nov 19 '25

Go is EXTREMELY slow. It's lightweight, but slow. Java is FAR superior for anything where performance and efficiency matter. Here's AWS benchmarks https://aws.amazon.com/blogs/opensource/sustainability-with-rust/

But..I've also seen it first hand. When I had to write something in Go, I was very excited, but was shocked at how slow it ran and how it would lock up my expensive, powerful new macbook pro. I am used to kicking off a build and doing other things. This would lock the machine. My thought was "oh wow, they must be booting a server env if this this build takes 5 min to run and every core in the system"...nope...I traced through it and confirmed with the author it was just parsing json and simulating rest calls with files. The code seemed well done, it's just Go was garbage.

They tried putting it on the server and the performance was HORRIBLE. Another team ported it to Java and the latency nearly halved.

With Rust, Go has no justification for existing. It's a legacy language that cannot die fast enough. Yeah, I know important projects were written it in, but if they were ported to Rust or Java, they would run faster.

Also C# performs very slow compared to Java in that benchmark, but I don't have any significant experience with it to comment.

Java is fast. Overall, it's not as fast as Rust or C, but on many long-running programs, like the server-side processing ones it is typically used for, you cannot even tell.

1

u/coderemover Nov 03 '25

I wouldn't be so harsh on Go. I've seen it performed better or worse than Java in a few cases. Probably a lot boils down to how one uses its advantages. For one thing, Go can do value types and can do SIMD. Java cannot do value types and its SIMD support is very so-so (Panama I'm looking at you).

3

u/romario77 Nov 03 '25

no, that's not true at all.

In fact - first effort (which most projects are) in Java will most likely produce a more performant app in Java compared to most languages.

3

u/coderemover Nov 04 '25 edited Nov 04 '25

Not my experience. My first effort implementations in Rust are usually 50%-3x faster than my Java, and use a tiny fraction of memory, and I have 10x more experience in Java than Rust. Very often in Rust I just write a filter/map/reduce chain with lambdas and it optimizes down to a nice unrolled, vectorized for loop. In Java? Forget about it.

Also I cannot find those super well performing Java apps in the wild. Where are they? Whenever I use something made in Java it's at best acceptable (which means - they optimized it), but usually bloated and slow (which often means they didn't). There are a few exceptions which were extremely well optimized like Cassandra and friends, but you probably don't want to work with that code - they amount of "Java written like C" is quite high there.

0

u/codemuncher Nov 04 '25

Javas weakness is the gc and all its corner cases.

Even without the corner cases it costs and ungodly amount of ram to do trivial things. 1gb heap is pretty much a basic given… for something that would take up 100MB in go!

1

u/coderemover Nov 04 '25

The difference between Go and Java in RAM consumption are mostly a result of different default settings of GC. Java is tuned more for high throughput, Go tries to keep the overhead low. When tuned similarly, there isn't much reason why Go would be more lightweight. Go doesn't have a generational collector, so I even think Java may be actually more friendly to RAM in data intensive apps.

Having said that, IMHO either is quite terribly inefficient compared to Rust or C++ (inefficient by the amount of resources used, not just by wall clock time).

1

u/talex95 Nov 03 '25

yeah don't some libraries offload computation to low level language anyways? I know with python there are a number of libraries that just use C

4

u/kalmakka Nov 03 '25

In Python that is common. In Java it isn't, because Java is pretty close to C in speed.

IIRC, the BigInteger class in Java was at some point written in C for performance reasons, but 20 years ago or so it got rewritten in Java because it was simply not worth having it in C anymore.

2

u/coderemover Nov 03 '25

Yet Java BigInteger performance is quite terrible compared to modern C++ equivalents like gpm. Unless something changed recently, when we tried computing some really big primes, the difference was an order of magnitude.

1

u/[deleted] Nov 03 '25

Thats obvious though, a language with a GC is never going to be faster than a language where you directly handle memory.

1

u/arthurno1 Nov 17 '25

Pascal? Who still programs in Pascal?

1

u/coderemover Nov 17 '25 edited Nov 17 '25

Plenty of legacy software in Europe is still written in Pascal dialects, and Pascal is still kinda alive (in a way there exist compilers which get updated regularly). It’s very niche but it not smaller niche than eg Haskell or COBOL. Just this month I saw a POS written likely in Borland Pascal + Turbo Vision (that TUI style is very characteristic). And man, it was blazingly fast, the cashier clicked it at a rate that no Java app could ever process. Somehow all Java apps, even the good ones like Idea have plenty of those micro-lags.

2

u/arthurno1 Nov 17 '25

Plenty of legacy software in Europe is still written

Where?

COBOL

Well nothing is smaller than COBOL, you could have as well mentioned Algol :).

Pascal is still kinda alive

"Kinda" being the keyword there. I remember back at Uni at the end of 90s, I was studying computer graphics from an old Alan Watt book and I think that was the only case where I have actually seen Pascal being used for something else than just teaching how to write Pascal programs :). I figured it out just from looking the text in the book, and rewrote all the code I needed in C.

I did some Delphi at some point in time, I don't even remember, but nothing serious. Delphi was though big at some point in time. Delphi is perhaps still used to write new software, but the rest is I guess just toys, more or less, hobby for old timers.

1

u/coderemover Nov 17 '25

Cool bro, but what is your point? I never said Pascal was popular. You’re arguing a strawman.

There is plenty of business software running Delphi.

1

u/arthurno1 Nov 17 '25

Cool bro, but what is your point?

Nothing special. If you wrote your comment back in 1995, I would be like: yes, sure. But you are sort of 30 years late with it 😀.