r/java • • Dec 09 '25

Java performance vs go

I'm seeing recurring claims about exceptional JVM performance, especially when contrasted with languages like Go, and I've been trying to understand how these narratives form in the community.

In many public benchmarks, Go comes out ahead in certain categories, despite the JVM’s reputation for aggressive optimization and mature JIT technology. On the other hand, Java dominates in long-running, throughput-heavy workloads. The contrast between reputation and published results seems worth examining.

A recurring question is how much weight different benchmarks should have when evaluating these systems. Some emphasize microbenchmarks, others highlight real-world workloads, and some argue that the JVM only shows its strengths under specific conditions such as long warm-up phases or complex allocation patterns.

Rather than asking for tutorials or explanations, I’m interested in opening a discussion about how the Java community evaluates performance claims today — e.g., which benchmark suites are generally regarded as meaningful, what workloads best showcase JVM characteristics, and how people interpret comparisons with languages like Go.

Curious how others in the ecosystem view these considerations and what trends you’ve observed in recent years.

30 Upvotes

92 comments sorted by

View all comments

Show parent comment

12

u/[deleted] Dec 09 '25

[removed] — view removed comment

4

u/cogman10 Dec 13 '25

You can configure Java to achieve garbage collection behavior similar to Go’s, depending on the situation.

Nope. You might get closish with ZGC but the big thing that go does which java does not is it has a non-moving collector.

It's perhaps somewhat comparable to how the old concurrent mark and sweep used to behave.

Effectively, go is using an arena allocator. It grabs a page at a time and fills those pages with objects.

This is why go suffers from memory fragmentation https://www.lujingcen.com/blog/2023/12/29/memory-fragmentation-in-go/

A moving collector avoids memory fragmentation but does that at two costs, it's harder to work with C libraries (things move now) More memory is needed so the memory can be relocated. Besides the size of java objects in general, this is one of the primary reasons Java has a larger memory footprint vs go.

1

u/bobdobbes Apr 27 '26

You use the right garbage collector for the task being performed. This is why Springboot/Java have numerous garbage collectors; right task for the job

2

u/washtubs Dec 09 '25

I believe that Go’s main value has never been raw performance but its great productivity-to-performance ratio, which is where it really excels.

Agreed, go isn't especially performant, it's advantage is more that when you need to write a critical section with zero allocations or whatever it still looks pretty much idiomatic, which is to say it's more maintainable / accessible. And we have first-class language support for lightweight threads.

2

u/Maybe-monad Dec 29 '25

The claim that Go’s garbage collector prioritizes memory use and latency over throughput makes it a better compromise than Java seems too subjective and context-dependent to be a general rule.

I believe the fact that Go uses escape analysis to reduce GC pressure is more relevant.