Programming in Go is surprisingly productive

My experience learning Go

In my work life I’m involved with projects in Ruby, Python, Swift, Rust, Javascript, Typescript. I don’t have strong programming language preferences and believe in the “right tool for the job” approach: the language should be a good fit for a problem domain, team expertise, time/budget constrains, etc. Rust is my go-to language when high-performance, strong type safety, rich ecosystem, compiled language is required.

Go is often suggested in similar circumstances, and I’ve read a couple Go books, but I could never understand why someone would prefer Go to Rust: Rust is much safer, much richer language; Rust’s strict and pedantic compile-time checks help avoid whole classes of bugs that could bite you in Go. Even when the features are quite similar (error checking), Rust approach (? operator) is elegant and makes the code so much easier to read.

However, some folks who I deeply respect suggest that I actually try writing some Go code, instead of forming an opinion by just reading it. When I was learning Rust 4 years ago, I wrote a simple app to set my Slack status to pre-defined values from a command line. I’m still using this app, it’s quite useful to write slack_status lunch and have my status changed in multiple Slack accounts at once.

I decided to rewrite this utility in Go. I must say, yes, it’s as annoying to write all those if err != nil { return err } as I imagined, and I didn’t feel as confident in the correctness of my code as I would have if this was Rust, but… I felt so much more productive writing Go!

The language is very simple, it rarely gets in the way Rust often does. The ecosystem is so rich there’s a module for everything. And the tooling is great too! I thought I’ll need at least a few days to rewrite slack-status in Go, but I was done in just a couple of hours.

Not every project needs the performance or the guardrails that Rust provides. I’m looking forward to dive deeper into Go and truly make it a part of my toolbox.

comments powered by Disqus