| Go's GC is much more naive than modern Java GCs, and the codegen is not terrific. That said: A few design decisions in the Java language (that are only slowly getting fixed) harm performance: 1. "Everything is virtually dispatched" reduces the ability to make inlining decisions sensibly.
2. Escape analysis gets harder (and less effective), leading to moving fewer variables onto the stack.
3. The poor support for allocating compound data types on the stack. All of these conspire to create many more heap allocations than comparable Go code, so even if the GC is much better, the amount of work it has to do is much bigger. Achieving any form of data locality in Java is also hard because it's really hard to nest structs. The Java design shows that the memory wall wasn't a thing yet when the language was designed... Things are slowly getting fixed, and there's a lot of interesting off-mainstream stuff that can be done to get more perf in Java-Land (Azuls JVM, Graals AoT etc) - but the strange thing is that Java does pay for some outdated design choices while Go performs pretty well despite a very simplistic implementation... |
you can use "static" keyword?..
> Escape analysis gets harder (and less effective), leading to moving fewer variables onto the stack.
does go have the same idea of escape analysis with benefits and issues?..