Unnecessary

Projects

About

The Go Language

Jul 1, 2019

When I was younger I would focus on a program for all day and into the evening. I would go to sleep thinking about a program, and I would wake up and jump right back into that program. During that time I kept a lot of the state of my program in my head, and I could write some very clever code. I moved through from primarily using C and thinking a lot about memory allocation to Java where I thought a lot about how my classes interacted, and eventually programmed primarily in python where I was able to rapidly create terse programs, however recently I have been experiencing a few issues in my programming productivity.

I am getting older and I have a lot of meetings, and that means that I often am reading the programs I wrote to figure out where I was going. Reading your programs can sometimes be a humbling experience, and I saw the deficiencies of some of my practices. I do not comment enough; I am inconsistent in how I choose variable names; And, I sometimes write things that are hard to follow. This reminded me of a famous Brian Kernighan quote:

Everyone knows that debugging is twice as hard as writing a program in the first place. So if you’re as clever as you can be when you write it, how will you ever debug it? (Kernighan and Plauger, 1978)

Another thing I noticed is that a lot of the mistakes I made could quickly be caught by type checking. I started using mypy on some new projects, but I also decided to start investigating the Go programming language which has become fairly popular. Go is designed to be a simple readable language which compiles to native code, includes garbage collection, and handles concurrency well. It is relatively lean in terms of language features by choice as initially all three of the language creators had to agree on every addition to the language. This makes it easy to learn, and means there will be hopefully few dark corners likely to confuse less experienced developers as they review other people’s code.

I have always enjoyed simplicity, and I like programming in Go. I find that I am less error prone as a result of the checking that automatically happens every time I save my program (I have configured vim to do this). There are three main features I want to highlight as those I particularly enjoy:

  1. Duck typing - A receiver automatically implements an interface if it has all the methods of that interface. This will be familiar for anyone coming from a python background.
  2. Garbage collection - Managing memory is difficult and error prone. Best not to think about it unless you have to.
  3. Gofmt - Formatting code is best left to a program, and Go has that program! This makes it a lot easier to collaborate using Go.

I think Go is well worth the time to learn, and an enjoyable language to use.

Tags: #thoughts #programming