Thoughts on Whatnot
A blog about .
The Problem with Interfaces
In a recent talk, Russ Cox asked Go developers to write about problems they’ve run into with Go in an attempt to help steer the design process for Go 2. In this post, I would like to attempt to do so by explaining some of the issues I have with Go’s interfaces. To start with, I think it’s best if I explain the problem I think that Go’s interfaces solve before explaining where I think they fail.
More...
Composition vs. Inheritance
There’s a situation that, while it doesn’t happen too commonly, annoys me when it does happen. Someone comes to Reddit, or golang-nuts, or somewhere else, and asks about the often repeated refrain about composition vs. inheritance. Sometimes, they get the right answer. Sometimes, someone makes some out-of-nowhere remark about embedding. The problem is that embedding is not in and of itself composition. It can be used in composition, but composition is not a syntactic or behavioral choice in the language; it’s a design pattern.
More...
Go Plugins
The release of Go 1.8 inches steadily closer, bringing with it many interesting and useful features and improvements, including shorter compilation times, an even faster GC, and, my personal favorite, initial support for plugins. Plugins, essentially Go’s version of C’s dlopen() and related functions, are an interesting one. The ability to dynamically load packages at run-time has been one of my most wanted features in Go since I first figured out how interfaces work.
More...
Redefining Go Templates
In Go 1.6, a new template action was introduced in the text/template package that allows for both defining and executing a template at the same time. This action, block, seems at first to be somewhat pointless. Even the docs describe it as simply being shorthand for defining and then immediately executing a template, and what’s the point of that? Why would you want to execute an inline template immediately after defining it?
More...
Interfaces and nil in Go
The oddity that nil interfaces can be in Go is one that has caught a number of people off guard. After explaining it multiple times on Reddit and elsewhere, I figured it would be a good idea to have an article I can refer to. Since I’m attempting to start a little blog here, I thought this might make a good first article. The problem is pretty simple. It’s very possible to have what appears to be a nil interface in Go which is, in fact, not nil.
More...