Learning Go

Go is simple, fast, and powerful. It has its' own oddities just like any other language but when you have a Gopher shaped nail, it's the perfect hammer.

Learning Go
Photo by Glenn Carstens-Peters / Unsplash

I've consistently favored C# whenever I needed to create a new API. The ecosystem is familiar to me, it has a thriving community of advocates and well-designed packages, and with the (relatively) recent addition of .NET Core, there's now flexibility to develop and deploy on platforms beyond Windows.

When a project with a focus on response time landed on my desk, my first instinct was to explore .NET Core Minimal API and I quickly developed a proof of concept encompassing all required features. While it showed promising performance, there was a challenge: I aimed to perform some background operations without delaying the HTTP response for the user.

This drove me to experiment with Channels. By producing messages to a channel and consuming them upon receipt, I managed to accomplish the background tasks even after sending out the response. However, over time, I faced issues like memory leaks, slower processing, and duplicate records. Although some of these problems might have stemmed from my unfamiliarity with Channels... (in true to myself fashion) I began searching for an alternative.

Enter Go

Well, Rust came first. I had been dabbling with Rust and Axum, and while they intrigued me, I wasn't ready to navigate the intricate syntax and language features at that time.

So now, Go.

I can't recall the exact trigger that got me exploring Go, but it emerged as the ideal tool for my requirements. After going through a few tutorials, notably "Basics of Go" by Maximiliano Firtman on Frontend Masters, I embarked on recreating my proof of concept using Go.

The transition was swift. Go's concepts resonated with me almost immediately. While it has peculiarities, like the absence of exceptions and types like Result and Option which I believe could be improved upon, my overall experience has been pleasurable.

What particularly appealed to me was the simplicity of dispatching background tasks using a Go routine. This eliminated the need for intricate channels, debugging in-memory queue systems, or leaning on SQS.

Lots to learn

Still, I'm a Go novice. Though I've been immersed in this project for only a few weeks, it has expanded to a point where more structured organization is imperative. There are moments when locating specific functions becomes a challenge.

Go's flexibility concerning project structure is both its strength and weakness. It offers liberty in structuring, but with that comes the potential for chaos.

One highlight, however, is Go's in-built testing. The simplicity and efficiency of this feature are commendable. While I've got more tests to implement, the process so far has been straightforward.

Infectious Development

Interestingly, a colleague discovered Go around the same time as I did, finding it equally apt for their needs. Our shared enthusiasm for Go fostered collaborative learning, making our development journey incredibly enjoyable.

Soon after completing my initial project, I embarked on another. With insights from my first application, this subsequent endeavor progressed even faster. It was surprisingly easy to visualize and address specific use-cases, allowing me to make significant strides in just one evening.

Gopher It.

Go is now among the first languages I consider for backend web tasks. While it may not always be the perfect choice, it's undeniably a valuable addition to my bag of tricks, and I eagerly anticipate my continued exploration.