Adventures in Go

As everyone who’s been around me for the past week knows, I’ve recently taken up learning Go. So far, the ride has been exciting and I’ve decided that Go is everything I wanted in a second language.

Ruby was the first programming language I felt like I mastered after using it professionally for almost two years. Even though there’s always more to learn, I feel comfortable with Ruby to the point where, when I set out to accomplish something, the language gets out of the way. It becomes invisible and is simply an extension of me solving a problem. While that’s a wonderful accomplishment, I’ve been on the hunt for a new tool to add to my repertoire, partly to expand my horizons as a programmer and partly to help me solve certain problems that Ruby is less than ideally-suited to solve.

Two concepts that have been at the forefront of my mind lately are scalability and concurrency. While Ruby and Rails are incredible tools for prototyping an idea and quickly building an end-to-end product, they tend to have difficulties at scale. And while you can certainly achieve concurrency with Ruby (and its thread-safe brethren Jruby and Rubinious), I knew there had to be better tools out there.

The Journey begins: Erlang

Around the time Facebook acquired Whatsapp for an eyeball-popping $19 bil, I became fascinated with their infrastructure. Certainly Facebook bought them for something other than the user base, right?

As it turns out, their infrastructure is incredibly efficient and can handle millions of messages per/second on a single server. Knowing this would be near-impossible to achieve with a standard Rails instance, I dug into their stack to understand what makes them so efficient. Nestled among a finely-tuned FreeBSD OS and impressive physical hardware was an exotic gem of a programming language, Erlang.

I spent a week reading everything I could get my hands on about Erlang, which as it turns out, isn’t much. Despite 27 years of being publicly available, only a handful of books have been written on the language and much of the community (libraries, frameworks, blog posts, tutorials) tend to be a year or two old which means they might as well be written on papyrus as far as the software world is concerned. Additionally, I found the language, albeit fascinating and offering powerful features for scalability such as the ability to hot swap code while it’s running, incredibly opaque and cryptic. To me, a difficult language combined with a steep learning curve and a dawdling community spelled failure.

An Elixir to my Erlang woes

As an alternative, I explored Elixir briefly. Elixir offers a Ruby-like syntax that compiles down to Erlang (like what CoffeeScript does for Javascript), and while it’s a promising effort, it’s young, rapidly changing and therefore not suitable for production-grade apps.

Additionally, adopting a high-level language without fully understanding what it’s compiling down into can be a recipe for disaster. While Elixir might be an appealing shortcut for experienced Erlang devs, it seemed unwise to learn Elixir without first understanding Erlang (just as one shouldn’t learn CoffeeScript, or jQuery without a firm understanding of the Javascript). While I’ll definitely keep my eye on it, it wasn’t what I was searching for at this moment in time.

A fling with Haskell

After putting down Erlang, I had a brief tryst with Haskell, but again I found it not right for my needs. It has a great community, and an active package system (Hackage), but its syntax was enigmatic and academic at heart (Monads, anyone?). And although it tends to perform better than a scripting language such as Ruby, performance and concurrency aren’t the primary goals of the language.

Enter Go.

So far, my quest for another language, one significantly different from Ruby and capable of handling scaling and concurrency with elegancy and poise, had had little success. After a tip from a friend, and seeing Go articles popping up left and right on Hacker News, I decided to learn what all the fuss was about. As it turns out, Go is exactly what I’ve been looking for.

What makes Go so special?

A few key items that have struck me so far about the language:

  • A simple, readable syntax that I’m familiar enough with knowing the C/Java family of languages
  • A shallow core language extended with packages (the Golang Book covers the heart of the syntax in just 8 short chapters)
  • It’s different enough from Ruby to give me a new outlook on solving programming problems
  • The community around Go is flourishing and seems to be growing exponentially
  • It comes with an awesome package management system built around tools I already use (Github and Bitbucket to name a couple)
  • Concurrency is baked right into the language with Goroutines and Channels
  • It’s compiled, statically typed and designed for practicality
  • Go has been exalted by several major tech companies that operate at scale

I may dive more in-depth into some of the features of Go in a later post, but needless to say, I’ve found my next language to master.

Andrew Allen

Author of, Software Engineer @Munchery, Former startup founder.

comments powered by Disqus