On Tuesday, 20 December 2016 00:31:52 UTC-5, Ian Lance Taylor wrote: > > [Go] is designed to let you control when and > how memory is allocated, giving you control over when memory is > allocated. The effect is that in Go you can adjust your program to > reduce GC overhead, rather than tuning the GC. This is far more true > in Go than in Java, since Java has no stack variables or structs. >
Regarding stack variables, Java and Go may be more similar than they first appear. Although Java's virtual machine places only primitive values and object references on the stack, and objects themselves on the heap, in practice, with similar escape analysis algorithms, Java compilers and Go compilers place the same set of objects on the stack. Structs/classes are where the real difference lies: Go lets you avoid unnecessary indirection (and its principal data types use fewer indirections: compare 1 pointer in Go's string to 3 in java.lang.String), and it is much harder for a compiler to do the analogous optimization to eliminate unnecessary references to indirect struct fields. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.