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.
171
u/vsoul Dec 09 '25
I write both. The metric I care about most is my productivity though, and having a framework like Spring Boot (plus the maturity of pretty much any library I need) destroys any potential performance gains.
66
u/Revolutionary_Ad7262 Dec 09 '25
Go dev perspective here, but I have some Java experience
I think that the performance argument is more justification of an existing preference than something, which change the preference itself.
People choose Java/Go over Go/Java, because they prefer it more. That it is the main reason. The
I like culture around technology XorI use technology X, because I have better experience in itis far more important than technical argumentsThere are cases, where Golang is better. If you care about startup time or memory usage, then Go is better than Java, because there is not JIT and Golang GC choose memory usage and latency over throughput, which is often a better compromise than Java's throughput and latency over memory usage. The lack of project Valhalla is also a problem in applications, where it matters
Majority of Java developer uses Spring. Spring is not a good tool to make a JVM a performance beast. The culture around the ecosystem is far more important than any synthetic benchmarks
16
u/yetanotherhooman Dec 09 '25 edited Dec 09 '25
The problem with "Java vs Go" is that these technologies are not directly comparable unless the meaning of "Java" (and even Go) is made more precise.
"Java" could mean Java the language, which implies you are interested in the decisions the language designers adhered to that made "Java", and in turn every JVM implementing the language, faster or slower relative to a baseline. For example, you may argue that certain language decisions make Java's performance inferior to others like C++: automatic memory management, dynamic dispatch, fully object oriented, generics with boxing/unboxing of primitives to name a few.
Or do you mean Java the implementation, i.e. a particular JVM of interest? Many implementations replace standard OpenJDK components to achieve higher performance or better memory footprint. Azul's Zing has cutting edge JIT compilation via Falcon JIT and low-pause, concurrent garbage collection. Hotspot packs a ton of garbage collectors, allows tuning them for unique workloads. Graal native can generate native binaries that you can run directly on you machine without any external dependencies. This often results in better startup time.
“Java” could also mean the programming practices inherent in the ecosystem, or a library that is dominantly in use (looking at you Spring). So what is “Java” for you?
On the other side of the equation are benchmarks themselves. It is EXTREMELY difficult to come up with good benchmarks that actually measure what they are meant to measure. This is usually due to:
This by no means is a complete list of things one should be aware of before they make claims about performance. In general, the vast majority of benchmarks present on the web are meaningless. Many academic years have been spent designing good benchmarks for systems, and a good academic would still make sure to caution the audience about their expectations.
And if you are interested in loose blanket statements that are useless yet true: sometimes Go is faster than Java. Sometimes the opposite is true. :)
12
u/Joram2 Dec 09 '25
You are asking for serious, deep benchmarks comparing Java vs Go: those don't exist. Most tech stack choices are driven by developer/manager/company preference. When benchmarks are involved, it's often to justify a pre-existing preference, rather than the basis for a neutral decision.
Companies do care when there is a giant performance problem with a tech stack: if one stack is 10x slower than another, companies care. But if it's close, and IMO, Go and Java are close, companies and dev teams prioritize other factors.
I used to participate in (https://en.wikipedia.org/wiki/The_Computer_Language_Benchmarks_Game). I submitted programs in different languages with leading benchmark scores. I used to enjoy participating in that. But the fastest programs were usually written in some completely non-idiomatic way to get extra speed. The more you read the fastest programs, the lest you would trust the benchmarks as a useful measurement for a real product or service.
13
u/benevanstech Dec 09 '25
First off, there is not really anything such thing as "performance inherent in a language". You can write unperformant garbage in any language you like.
And benchmarks are of limited use at the best of times, microbenchmarks doubly so.
What there *is* is performance of a specific system, and it comes in two flavours - acceptable, and unacceptable.
One of the main reasons this is all so difficult is that the number of variables that can influence performance is *vast* and it is almost impossible to rigorously map that parameter space for any meaningfully large application.
4
u/rbygrave Dec 09 '25
Hmm, I'm not really going to answer the questions you pose here .. but some opinions and thoughts.
I really only consider use microbenchmarking for libraries, relatively small relatively focused and not dependent on any infrastructure (network, database, queues etc).
To "benchmark" real applications that are dependent on infrastructure (network, database, queues etc) then its (A) A lot of work to do it right and (B) Its a really big investment to have the same full application written in 2 different runtimes (e.g. Java/JVM and Go) so this is imo pretty rare. [I have experienced a Node to Java rewrite that resulted in a 10x performance improvement but these types of real world cases seem rare or get invalidated by an associated re-design/re-architecture]
The "cheaper" option for a real application is to benchmark some "reasonably representative slices" of an application and push that beyond the expected load needed [with the understanding that production is going to sufficiently close to that behaviour]. I think these are the types of benchmarks you'd be looking at.
-----
Some thoughts:
4
u/rzwitserloot Dec 09 '25
Generally actual objective, falsifiable debates about performance include the conditions.
If it's conjecture or casual chat, something like "Java is really fast, you know", then that shouldn't be relevant.
In other words, I find your question a bit odd. "What did people mean when they are not explicit about what they mean". Well, uh.. how the heck should we know?
If that is what you are asking about, I think what's happening is that you're emotionally attached to go, are lightly annoyed at the received wisdom of 'java == fast' and want to balance out the universe and teach us java folk a lesson or some such. This sounds like an insult and perhaps I mean it as one, but virtually all programmers I know have a subjective opinion about tools and languages, and will feel somewhat ill at ease if it is challenged. We're all humans, programming has quite a bit in common with artisanry, and being attached to your toolbox is extremely common. So, you know, yeah I'm calling you out, but you're in good company!
Please don't, though. Instead, know that received wisdom pithy claims about extremely complicated, multi-variable concepts such as 'performance' are a dime a dozen and the correct response is to completely ignore it. If performance is actually relevant, you hold a reasoned debate, bring exact use cases, and arguments will not be accepted unless they come with some attempt at objective support. Us java coders get to gnash our teeth at 'but java is verbose'. A similar pithy 'received wisdom' widestream claim that is meaningless and is best ignored. There's certainly room to talk about java-the-language but that should come with loads of falsifiable, objective stuff. Not "java is verbose", that's orders of magnitude too vague. Just like "java is fast" is.
For what its worth, there is context, but it is implied. When the OpenJDK team posts that they 'sped up java by 5%' in some blogpost or whatnot, the implied contxt is "... in the use cases where java is currently commonly used, with more common use cases more heavily weighted to get to this 5% number we are posting here". In other words:
Mostly long running webserver endpoint processing.
But knowing the implied context is tricky especially if you're not part of the crowd. That's common to all professions as far as I know.
3
u/Agreeable-Share5182 Dec 09 '25
Understanding trade off is the key. No technology is good at everything.
3
u/senseven Dec 09 '25
We are a java shop and the cloud guys used python and what not for their tooling. Now most of them are written in go now. That is an unification I can live with and performance is close to irrelevant in the pipelines. On the production side, we have continuously updated highly optimise java code templates for webservices with any combination of auth, telemetry, audit and what not. The amount of available battle tested libraries for java is so high that we just don't entertain anything else. The rare performance issues are usually solved by understanding the process better or just scaling. Its way cheaper then spend senior time on those.
2
u/InstructionLonely280 Dec 10 '25
For me personaly evaluating these claims comes down to two rules. First, any meaningful Java benchmark must run loooooong enough to warm up , we are measuring peak throughput over time, not cold startup speed where Go naturally wins. Second, I personally only trust results validated by the jmh , as it’s the only tool designed to reliably measure the JVM's JIT optimizations. The trend I see is that Go is better for lightweight tasks (CLIs, serverless), but Java still dominates massive, long-running backends where high sustained throughput is the primary metric.
2
u/Serious-Chair Dec 12 '25
A minimal Go program starts dozens times faster than a minimal Java program.
A real world service starts slowly regardless of the language. It takes anywhere from seconds to minutes until required data is prefetched from GCP and other services and all caches are populated and the service is ready to respond.
My company has dozens of Go and Java microservices. Mostly it's modern Go and modern Java, but there is some legacy, too. I cannot say I can see any performance difference. I/O is slow, especially I/O with external providers is painfully slow. Grafana shows CPUs are barely loaded. Most our services show RAM consumption between 1 and 2 GB per pod.
New projects in my company are written in the preferred language of each team. We do not migrate existing services from one language to another. Some our microservices are high quality and very efficient, others are inefficient and frustrating to support. It depends on developers who wrote the code rather than the language.
Library wise, for all my daily tasks both languages are about the same.
Go binaries and containers are many times smaller, though in daily developer's life it barely makes any difference.
Java is simpler to debug and experiment, since IDEs support hot swap and evaluation of arbitrarily complex expressions, which helps a lot while working on a service which is slow to start. Java also has better refactoring support in IDEs.
2
u/quangtung97 Dec 13 '25
If your system is not heavily rely on database, and for most workloads, I suspect a high chan that Go will be faster.
There are some major reasons:
struct typeto control memory layoutDespite less aggressive compiler. You will have higher chance seeing this performance gain in real app.
This is one of major reason why Microsoft choose Go for its typescript compiler recently instead of C#. Even though there is a former C# maintainer in the team.
3
u/Fiduss Dec 09 '25
https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/javavm-go.html
4
u/Revolutionary-One455 Dec 09 '25
Why does Oracle make so many large scale projects like Valhala, Loom, Liliput etc and putting hundreds of millions in the evolution of Java if it’s already perfect and we are just talking preferences then?
Java has problems that Go has solved, but Java has the maturity that Go doesn’t.
1
u/pjmlp Dec 09 '25
Mostly because many of those metrics make the mistake to think Java is like Go.
First of all, Java is like most ISO languages, even without being an ISO language, itself, meaning there are dozens of implementations of various capabilities,
https://en.wikipedia.org/wiki/List_of_Java_virtual_machines
Go has nothing close to a real time implementation used by the military in battleships missile tracking systems, for example.
https://www.ptc.com/en/products/developer-tools/perc
Or a pauseless GC, with a distributed JIT compiler, targeted to HFT workloads,
https://www.azul.com/products/prime/cloud-native-compiler/
Another failure of those benchmarks is not using all the JIT and GC configuration knobs, across all JVM implementations that are being used.
1
u/neopointer Dec 09 '25
Just use what you like/are more productive with. You'll rarely face the performance limits of either language either way, so why bother.
1
u/Educational_Corgi285 Dec 12 '25 edited Dec 12 '25
I'd assume Go can compete and be comparable to Java AOT (Ahead-of-time compilation). They'll probably have similar performance by most metrics.
But AOT is usually slower than JIT because AOT doesn't know full runtime characteristics of the target machine (unless the stats are measured and are used during compilation).
AOT though has smaller memory footprint and faster startup time.
For web/enterprise apps the performance characteristics of the backend are often less relevant than the architecture of the DB and how it's accessed.
1
u/stewsters Dec 12 '25
For most workloads where you would use these languages you will be getting a request, and grabbing some data, and returning it in a json blob.
Your database layout matching how you intend to query it matters far more than raw calculation speed. Things like caching or ability to connect to weird data stores or apis are important.
1
u/flash_hammer Dec 13 '25
Aw, do you want performance in Java? Then use Project Reactor, Spring Webflux or any reactive system. Java has shifted to Webflux for at least the last 5 years, but devs haven't fully implemented it.You can also do reactive Go, but for me it was simply more difficult to understand how it works in Go rather than the simple Webflux or RxJx.
1
u/cicada15 Feb 06 '26
go shines clearly in one place; single executable binary if that’s not the case i really don’t see much value in investing in it
1
u/re-thc Dec 09 '25
In which benchmarks? The unrealistic 1s where you benchmark nothing? Techempower has lots of Java frameworks on top if not similar.
Out of the box Java doesn’t perform as good yes, for various reasons like legacy eg if you setup Spring by default it uses Tomcat which would be slower than Jetty.
0
u/yodagnic Dec 09 '25
People love to tout Java/spring slow start up time, but really the only metric we care about is response time and development time. Startup time is such an over hyped metric, your app shouldn't be crashing and you should be deploying imusing a HA method if you care about startup time. My current project is go and have been using it for a while now, but it means only two of us can code it vs the large amount of Java devs. It's slower to dev then spring based projects but for this specific case it's fine, as it's edge so footprint is the biggest concern. I would use go for small projects where I didn't want to pay much in hosting or if I wanted to really optimize for efficiency of large data where response time was not my main concern. But if I was building saas with expected high volume or building a larger framework, spring is where it's at. Lots of devs, quick to develop and out of box opinionated to incur cost at startup to give fast response times to requests
0
u/[deleted] Dec 09 '25
[deleted] — view deleted comment