Go is Weird

Go is weird. For all its intended (and frequently achieved) simplicity and straightforwardness, I keep being surprised by its rough edges and seemingly arbitrary corner cases. Here is one.

Who is Responsible for Writing Go Interfaces, Anyway?

For every function, data type, or other such code artifact, there are two bits of code: the part that defines and implements it, and the one that uses it.

As I have been thinking (here and here) about the proper use and understanding of Go’s interface construct, the question came up, who is actually responsible for writing the interface: the person who defines the data type, or the person who uses it?

Go Interfaces and the Handle/Body Idiom

The interface construct in the Go language is one of its most immediately visible features. Interfaces in Go are ubiquitous, but I am afraid that the best way to use them has not yet fully been explored. Moreover, in practice, Go interfaces seem to be used in ways that were not intended, and are not necessarily entirely beneficial, such as an implementation shortcut to the classic Handle/Body idiom that hides interchangeable implementations behind a common, well, interface.

A Guide to git: Three Essential Hidden Concepts

Like many other people, I have struggled with git. It was obviously all very clever, but somehow inexplicably difficult and frustrating to use.

Eventually, I realized that my difficulties stemmed from three misconceptions: areas, where git did something different from what I thought it did, or different from what I was led to believe it did.

Random Shuffles

Shuffling a collection of items is a surprisingly frequent task in programming: essentially, it comes up whenever a known input must be processed in random order. What is more, there is a delightful, three-line algorithm to accomplish this task correctly, in-place, and in optimal time. Unfortunately, this simple three-line solution seems to be insufficiently known, leading to various, less-than-optimal ad-hoc alternatives being used in practice — but that is entirely unnecessary!