2 ms·
Indeed, and Hotspot is one of the crown jewels of the Java universe. Speed comparisons between Java and Go are not simple, because they are very different beast
by _ph_ 9y ago
Indeed, and Hotspot is one of the crown jewels of the Java universe. Speed comparisons between Java and Go are not simple, because they are very different beasts. Java has a JIT which compiles code at run time. Hotspot is very good at using run-time information for optimizing the code. The Go compiler of course compiles in advance - so it lacks some information Hotspot might have, and is first of all tuned for compilation speed. But a lot of work has gotten into the Go compiler, and the work continues, so over time one can expect it to emit better code - the Go maintainers are usually very happy about use cases, where components don't behave as expected and improve the corresponding parts.
This blog post compared a very small benchmark between the two languages, but for larger applications, the different way of doing things in Java and in Go has a big impact on performance. The Java object model brings a lot of overhead for memory allocations vs. the Go value types. So at minimum one would expect those languages to have different performance characteristics.