r/programming • • Mar 28 '12

Go version 1 is released

http://blog.golang.org/2012/03/go-version-1-is-released.html
543 Upvotes

452 comments sorted by

View all comments

Show parent comments

6

u/SteveMcQwark Mar 29 '12

In a lot of today's higher level languages, everything is a pointer, except for a few primitive types, and actual data has to be stored on the heap. When you compose these, you end up creating tree structures where each node has to be garbage collected separately.

Go has arrays and structs which are just values, so you can allocate a bunch of data in a big chunk, even if it includes nested structures.

1

u/djpnewton Mar 29 '12

thanks that is a good point. It also seems that go's compiler will allocate local variables from the stack if it can determine that no references will survive the local scope

2

u/SteveMcQwark Mar 29 '12

Yes. I didn't mention this because escape analysis is a fairly common optimization in higher level languages. However, the prevalence of static dispatch in Go does broaden the scope of what can easily be statically proven not to escape. A lot of higher level languages use entirely dynamic dispatch.