Craig Weber

Go's interfaces and nil by example

I've recently been involved in conversations with a few Go developers who have expressed frustration about Go's interfaces with respect to nil. It seems not everyone understands that interfaces are a reference type (like a pointer), and they can reference other reference types (i.e., pointers, maps, slices, etc). Because all reference types have a nil (zero) value, an interface can be nil or an interface can reference a nil pointer; people may fail to realize that the nility of the interface is independent from the nility of the thing it points to, and when we ask (for example) if err != nil, we're actually asking is the interface nil?, not is the value behind the interface nil?. Here are a few examples that will (hopefully) demonstrate this clearly:

Read More

Benchmarking Go and Python

Sometimes I'm curious about the performance of different languages. At work, I usually write Python, but I often find tasks that are inherently parallelizable and could thus benefit from parallel execution. Unfortunately, Python is notoriously difficult to parallelize1. In one case, we needed to validate that a table of values of a particular type could be convertible into a values of a different type based on some known set of conversion rules. Since Go is a great language for writing concurrent programs (and executing them in parallel), I decided to compare a sequential Python implementation to sequential and parallel Go implementations.

Read More

Installing Go on Linux & OS X

This is a guide for Unix systems (OS X and Linux), but Windows users shouldn't find it too difficult to figure out the equivalent commands for their platform. I'm not assuming much prior knowledge, but readers should at least be comfortable navigating around a Unix terminal, and any familiarity with environment variables is helpful (a quick Google search for "environment variables" should suffice). Without further ado:

Read More

Software architecture best practices

This is a collection of articles I've found about software development best-practices. I intend to add to it over time, so don't be surprised if it changes. Read More