Happy new year to one and all. It’s been a while since I posted and life continues onwards at a crazy pace. I meant to publish this post just after Christmas but have only found time to sit down and write now.

If anyone is wondering what’s with the crazy title – a gopher is someone who practices the Go programming language (just as those who write in Python refer to themselves as pythonistas. There’s an interesting list of labels that programmers self-assign here if you’re interested).

Over Christmas I decided I was going to have a break from working as a CTO and a PhD student in order to do something relaxing. That’s why I thought I’d teach myself a new programming language. I also taught myself how to use Angular.js too but I’ll probably write about that separately.

Go Go Gadget… keyboard?

First on my list is the Go programming language. I decided that I would spend 2 weeks over xmas (in between playing with my nintendo switch and of course spending time with my lovely fiancee and our families) building something useful and practical in the language because if there’s one thing I can’t stand its trying to learn to use a programming language by writing yet another todo list.

Chatty Cathy – she’s still very much a work in progress

At Filament, we are fast becoming one of the UK’s leading chat-bot providers, working with brands like T-Mobile and Hiscox insurance. We have an excellent team of chat-bot builders run by our very own Mr Chat-bot, Rory and supported by  a very stringent but also very manual QA process. I decided I was going to try and help the team work smarter by building a PoC chatbot testing framework.

The general gist of my tool, named Chatty Cathy, is that I can “record” a conversation with a bot, go make some changes to the intents and flows and then “playback” my conversation to make sure the bot still responds in the way I’d like.

Why Go?

Gophers are pretty cool!

If you hadn’t gathered, I’m in to performance-sensitive compute applications: AI, statistical modelling, machine learning, natural language processing. All of these things need a lot of juice. We’re also in the business of writing large-scale web applications that serve these kinds of machine learning models to huge numbers of users. I love python and node.js as much as the next man but most machine learning applications that have interfaces in those languages are written in something low level (C or C++) and bound to these higher level languages for ease of use. I know that Go is still higher level than C or something like Rust* but it outperforms all of the interpreted languages and Java in the Benchmark Games and is very easy to learn (see below). It is this trade-off relatively-high-performance-versus-ease-of-use that has me so excited.

*Incidentally I spent some time last year working in Rust and even though I loved it, found it very hard going  – I’ve been following Julia Evans’ Ruby Profiler project and it’s got me excited about Rust again so maybe I’ll dive back in some day soon.

Pros of Working with Go

    • Go-lang is like a pared down, simplistic dialect of C. You could also think about it as a much simplified Java spin off.
    • The build tool is amazingly simple to use. Everything is done based on filenames and locations. No more over-engineered pom.xml or package.json files.
    • Like Python and node.js, Go has a huge number of “batteries included” modules and functions available as part of its standard library. Web applications and JSON are first class citizens in Go-lang and you can build an app that serves up serialized json in ~30 lines of code. (compare that to the 300 lines of code you need just to define your POJOs and your DTOs in Java and you can already see why this is so awesome).
    • Also like Python and node.js Go has a brilliant ecosystem. One of the perks of coming into existence in the golden age of the internet I guess. Go’s build tool can automatically grab other projects from git repositories without needing a centralised server like pip/npm/maven which in my eyes makes it even more awesome (no more left pad chaos).
    • Unit testing is also a core part of the language and build tool. Simply adding some files to your library with the suffex _tests.go  running go test is all you need.
    • Go’s goroutine interface for parallelism is a super exciting feature. Again, having been designed very recently in the age of multi-core processors, the language treats multi-core processing as a first class citizen. Compared to Python which is held back from multi-processing bliss by the GIL and node.js which uses a single event loop.
    • Biggest pro: learning curve. For someone who’s written in any kind of imperative programming language before and has some level of understanding around pointers and referencing, Go is SOOO easy to pick up. I reckon the java developers at our company could be effective in Go within a week or less. (If you’re reading Rob, Max, Alex, that’s a challenge). It truly is like Java without the bulls***!
  • Cons of working with Go

    • I still find workspaces kind of a strange concept. Instead of checking out one git project and popping it in your $HOME/workspace directory (yes this is a hangover from years of Eclipse development when I was back at big blue), code is stored hierarchically based on where you got it from. For example my workspace looks a bit like this:
    go
    └── src
     ├── github.com
     │ ├── author1
     │ │ └── project1
     │ │ ├── LICENSE.txt
     │ │ ├── README.md
     │ │ ├── somefile.go
     │ │ ├── more.go
     │ ├── author2
     │ │ └── project2
     │ │ ├── LICENSE.txt
     │ │ ├── README.md
     │ │ ├── somefile.go
     │ │ ├── more.go

    Basically, each project gets stored somewhere hierarchically in the tree and all dependencies of your project end up somewhere in here. This can make it a little bit confusing when you’re working on really large projects but then perhaps this is no more confusing than a python virtualenv or the node_modules directory of a mature node.js app and I’m being silly?

    • Some of the libraries are still a little bit immature. I don’t mean to be disparaging in any way towards the authors of these open source libraries that are doing a fantastic job for absolutely zero payment. However, a lot of the java tooling we use at work has been in development for 2 (in some cases nearly 3) decades and a lot of the crazier use cases I want to try and do are supported out of the box.
    • I’m still not a massive fan of the way that struct tag syntax works. Again, perhaps this is because I am a programming luddite but I definitely prefer Java Annotations and Python Decorators a lot more.

    Summary

    Go is a really exciting language for me personally but also for many of us still plagued by nightmarish visions of java boilerplate in our sleep. It has a fantastic ecosystem and first-class support for parallel programming and building web services via a really nice set of REST server libraries and JSON serialization libraries that are already built in. There are a few small issues that probably still need addressing but I’m sure they will come out in the wash.

    The most exciting thing for me is how well Go slots into the toolbox of any competent imperative language programmer (e.g. C, C++, Java, Python, Javascript, C#, PHP etc.). Whichever language you come from there are likely to be a few minor changes to get used to but the syntax and concepts are familiar enough that you can be up and running in no time at all!

    Is Go ready to be used in prime-time production-ready systems? I definitely think so but if you don’t believe me, why don’t you ask the Docker Foundation?