|
|
|
|
|
by azakai
5086 days ago
|
|
> Go's model is such that, compared to JVM-based languages, you have the control to create (much) less garbage in the first place, greatly reducing the size and impact of garbage collection pauses. I have only heard of escape analysis (which Java has) and structs inside structs (which C# has; C# also lets you put structs on the stack). Is there anything that Go has over Java and C#? |
|
In Java all objects are passed by reference, which causes bloat and cache locality issues. Also there are bookkeeping costs associated with even trivial objects: a simple array carries around an additional 16 bytes of memory.
Furthermore, the core Java libraries make it very difficult to write code that doesn't generate a lot of garbage. In fact, it's very difficult to write allocation-efficient code in Java without writing very unidiomatic Java code. These problems are worsened in more dynamic JVM-based languages like Scala and Clojure, which generate huge amounts of garbage due to runtime reflection.
Here's an interesting discussion of these issues:
http://loadcode.blogspot.com/2009/12/go-vs-java.html