Touring Go

By Will Angley
07 Jul 2014

After working at Google for a bit less than a year, I’m about to start working on some internal projects that use the Go language. I’ve had to learn the language from scratch, and spent the last couple of days working through A Tour of Go to do this.

I think I’ve tried it a few times before, but this is the first time I’ve made it through to the end. Having specific work in mind definitely helped here.

Thoughts on getting set up

I had reservations about the setup process, but actually working through it showed that it was fairly straightforward to do. It took about twenty minutes:

  • When it was actually time to install Go locally, it was as easy as brew install go.
  • Go’s concept of a runtime path (GOPATH) is different than most other languages I’ve worked with, so my Go code doesn’t live in the same place as any other code on my computer does. But it’s been painless once I decided on a location for it.
  • I’ve been happy with the editor support in Vim.
  • Getting godoc to work was the “toughest” part - it took a bit of searching to do, unlike the rest of the steps above. But it made the exercises a lot easier once I did.

Thoughts on the tour

The tour doesn’t let you log in to save your state, so I wound up typing the same exercise several times as I switched computers (or rebooted them for updates) over the course of the tour. I learned my lesson and started saving the files to GitHub before getting to the bigger exercises at the end.

The language itself has been really pleasant to work with, and the tree comparison exercise solution was enough to sell me on it: it’s really amazing to be able to read input and output across routines. I’m probably going to have to write a bunch more programs in it before I feel comfortable though.

I feel like the tour buries the lede here though. This exercise is ten slides after the point where I gave up last time (when it asked me to set up a local server) and I hope I would have kept going if I’d read that then.

Both my solution (no link at the moment) and the Go Author’s solution to the Web Crawler exercise at the end make use of language features that aren’t actually covered in the tour. I struggled for a bit trying to fit the solution into features that were included, and a note that you should check the sync package documentation out would go a long way here.

On what I’ve seen of the language

Being able to write tree algorithms neatly out-of-the-box is a really nice feature to have, and I’m probably going to start looking for problems to use it on now. Project Euler, and some of the Coursera optimization classes, come to mind right away. Go was clearly designed to be good at these, and it shows in the first few hours of work.

The built-in HTTP support is really nice, and is a major step above other systems I’ve worked with. I’m looking forward to seeing what I can do with it.

The experience of compiling and running a tiny program with go run is really nice compared to Java, and not having to write (C|Pre|Auto)?Makefiles is really nice compared to C and C++. It’s just as easy to throw something together in Go as it is in Python, and I’ll probably be doing a lot more of this now.

Reservations

I’m still feeling a bit of missing feature anxiety; I found the combination of slightly stronger-than-Python typing with no generics uncomfortable when I tried programming in raw C the last time (about a year ago). Although I know Go typing is smarter than this, I feel like I’ve gotten used to counting on these in my designs.

The lack of a built-in interface to the windowing system is a bit of a shock. Although it doesn’t matter in The Cloud, when running locally I feel like I’ve lost something that I was able to do well in 2002 in Visual Basic. To this day I’m more comfortable drawing diagrams in Tkinter than I am in a web browser, and browsing to web servers on localhost:SOME_BIG_PORT_HERE still doesn’t feel completely natural to me.

What I’m going to do next

Write more Go programs, of course! This is the first time in a while I’ve been excited to learn a new programming language, and I want to take advantage of it while the excitement lasts.

Quite probably, brush up on my ‘drawing pretty pictures in a Web browser’ skills. I have a pattern book full of pretty pictures, Tufte’s The Visual Display of Quantitative Information, that I haven’t gotten to draw from in a bit too long, and I’d like to put some of them to use while I’m doing the above.

Read How to Write Go Code, the language specification, and Effective Go after I’ve written enough code to appreciate each in turn.

Update my résumé to include 0 years of Go experience, and see how many recruiters find me with buggy regular expressions :smile:.