Interfaces and Nil in Go, or, Don't Lie to Computers

It is commonly held up as a wart in Go that interfaces have "two different nils"; one is when the interface value is nil:

var something interface{}
fmt.Println(something == nil) // prints true

and one is when the interface contains a nil:

var i *int // initializes to nil
var something interface{} = i
fmt.Println(something == nil) // prints false

This is not a wart in Go. It is a result of a programmer misconception combining with a software engineering bug which results in an attribution error.

Why Go Getting Generics Will Not Change Idiomatic Go

After years of overly-acrimonious online discussion, Go is continuing down the chute towards getting generics. I'm already seeing the inevitable "functional" libraries (plural) coming out. I'm going to explain why none of these libraries are going to materially impact what the community considers good style.

They may see some use. I may even use some of them myself on small scales. Some iconoclasts will program with them extensively, and their code will work, in the sense that it will do what it was designed to do regardless of how the code reads. But they are not going to change what generally-good style is considered to be.

Edit: May 2021 - Update for the latest generics syntax.

Why Duck Typing Is Safe

For the last 20 years I've been programming almost exclusively in languages with either duck typing or structural typing. These are languages where you can have objects that either conform to an informal interface without that conformance being declared (dynamically-typed languages), or where conformance is simply a matter of matching the interface (Go). This is as opposed to languages where conformance must be explicitly declared somehow, either with a formal subclass relationship (the class-based portion of C++) or by explicitly declaring conformance to an interface (Java).

Not needing to formally declare conformance is powerful because you can take some pre-existing object, declare a new interface that it conforms to, and then use it with your interface. This reduces the endless paperwork around re-wrapping things to make existing objects conform to new interfaces.

I have seen a lot of programmers over the years express concerns; what if something accidentally conforms to an interface and causes some horrible bug? What if I have an interface for Shoot() for a video game and some object wanders in that Shoot()s a real gun by accident? Isn't it safer to formally declare conformance?

Stream Resolutions Are Quality Maximums, Not Minimums

From the "It's Obvious When I Say It, But..." department: I recently figured out to put something into words that has been bothering me for a while: We tend to treat stream resolutions as putting a minimum guarantee of quality on a stream. Thus, a "720P stream" must be lower in quality than a "1080P stream", which must be lower in quality than a "4K stream". This is backwards. Stream resolution puts a maximum quality on a stream.

While writing comment on another site, I accidentally came up with what I think is a pretty good definition of "gimmick", since the internet tends to throw the term around with wild abandon. A storyteller that likes getting paid should do things that make the audience want to come back for more. A gimmick is when you do something that win in the short term, but is ultimately burning your audience as they tire of it.

Aging in the 21st Century

It's abstract to think about how one will someday be old and feeble, but as I was filtering over some spam a moment ago, it occurred to me that someday, my children will have to take away my email because I won't be able to properly process Mr. Al-Amin Dagash's email titled REQUEST FOR A LEGITIMATE BUSINESS PARTNERSHIP. Now that's a sobering thought.

Around about 1998, I was talking to my electronic music teacher and ethused about the day that would come when we could put, say, everything Mozart ever did on a single cube, holding my fingers up in the air separated by about an inch. "You know, not everything Mozart did was great." "No, I get it, I just mean him as someone who put out a lot of stuff. Everything the Beatles ever did would work, too.

The generation gap just isn't what it used to be. A couple of weeks ago I watched this video, a weird lip-sync riff on Star Wars. Fine. A moment's amusement, sure, and on I click. Two days later I went to a birthday party with my kids, and as the older kids were running around I hear one of the 12-year-olds murmuring the lyrics of this song to himself.