August 13th, 2024 08:08 UTC · 3 months ago

Golang

Relearning Go

Why am I doing this?

Recently I have been relearning Go, the programming language, and I have been journalling my experience. Over the next couple of weeks I’ll be posting my journal as I learn, again.

For context, Go and I have never been friends. I’m not a hater from afar though: I wrote Go professionally for several months about a decade ago, so I do have some idea what I’m talking about. At that time I was mostly doing Python, which I liked. Since then I’ve written a lot of Python, Elm, Haskell, JavaScript/TypeScript, Rust, and some Ruby and Elixir – and yet Go still holds a special place in my heart as the language I like the least. Or dislike the most.

Why I don’t like Go

You can skip ahead a section if you want; you’ll be familiar with much of this if you’ve been around the Go ecosystem for a while. The point here is to express my negativity before I set about relearning the language, a catharsis of sorts to clear my mind and give this experiment a better chance of success. I want a positive outcome! Nevertheless, I am starting from an entrenched position of rejection towards Go; read this series with that in mind.

Some of my objections are technical, like:

  • No result types. Indeed, the whole cringe-inducing-ly awful way errors are constructed and propagated.

  • No option types. Zero values 🤮

  • Interface nil values.

  • Lack of generics. I know this has been addressed now and I’m curious to know how well it works.

But what alienated me most was the post-hoc rationalisation of language warts. See the interface nil values documentation for one example.

Early on I also heard that Go had been designed for junior programmers, fresh out of college and coming to Google. It would help them quickly be productive. I read: it’s a dumbed-down language for cube farms. Nothing has moved the needle on that take in the years since.

Go was and mostly remains small, which is a winning feature for a language intended to be easy to learn, right? Yet it also means that as you grow as a developer you will remain limited to speaking with the programming equivalent of a child’s vocabulary.

Then, even though small, Go felt incomplete, or incoherent – and still does. I was coding Python back then but had been learning Haskell, which introduced me to Maybe and Either (and much else; even at the time I quickly realised how useful learning Haskell was to my Python skills). Go, this new language with the freedom and scope to learn from progress and research, instead birthed its awkward thing, err := … form, recommitted the null mistake, and introduced zero values. What remaining hope I had did not linger long: Go was a missed opportunity.

To cap it, Go’s dedication to backwards compatibility meant it ossified this way. It felt like the language designers were trying to win an argument from 1979 and were stuck, arguing the same point over and over. Can we move on now? Oh no, sweet unenlightened summer child: we’re going to keep going until the received wisdom is fully assimilated.

Oh, just one more thing

What I’ve already said is plenty, but I have one more bias to disclose. The company at which I worked all those years ago decreed from the top: use Go. In my tenure we’d had a spotty history with these kinds of edicts; adopting YUI was one such bad-at-the-time and bad-in-retrospect decisions. It was determined that a flagship product would be entirely rewritten in Go. The product was novel and exciting – and the rewrite stalled its development for 18 months for no clear benefit. It’s now one of the long tail of also-rans in its product category. I don’t know if the rewrite was the reason it’s irrelevant now, but it also didn’t help.

In case it wasn’t clear

I am biased against Go. I will not, cannot, be objective. I want this to work, but it’s going to be a bloodletting in one of its senses: either my distaste will be diminished and I will find a new appreciation for Go, or I will choose violence. Let’s be honest, it’s going to be both, isn’t it?

Why am I doing this?

In spite of my criticisms, Go is thriving, and a lot of good software has been written with it. It’s as much part of language discourse as it ever was. Lots of companies are hiring for it.

I’ve also gotten older, mellower, wiser perhaps. It’s time to revisit this old foe and see if we have some common ground. Undoubtedly there’s something I can learn from the experience.