Get the latest tech news

Go Data Structures (2009)


Posted on Tuesday, November 24, 2009. When explaining Go to new programmers, I've found that it often helps to explain what Go values look like in memory, to build the right intuition about which operations are expensive and which are not.

defines a simple struct type named Point, represented as two adjacent int s in memory. Even with a fast allocator, that creates a lot of unnecessary work for the garbage collector, and we found that, as was the case with strings above, programs avoided slicing operations in favor of passing explicit indices. Removing the indirection and the allocation made slices cheap enough to avoid passing explicit indices in most cases.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of data structures

data structures

Related news:

News photo

Good programmers worry about data structures and their relationships

News photo

Go Algorithms and Data Structures: Best Practices for Beginners

News photo

Automerge: A library of data structures for building collaborative applications