Sorry, Ruby — I think I’ve fallen for Go!
It was just about ten years ago that the initial commit of the iconic Ruby on Rails app framework was published. It almost immediately began sending developers like me into somewhat of a frenzy.
I began to digest and understand Ruby (and Rails) and realized — hey! — this was the first time any language just made sense right out of the box. The code read like a developer’s love poem. Concepts previously foreign to me such as “model-view-controller” seemed to suddenly click. No longer was I struggling to understand syntax as I did with PHP or Perl. I was able to splice together a rough (but working!) prototype of a web app in as little as a few days.
There was no mistaking it…
I ❤ Ruby!
Over the years as I became fluent in the Ruby language, I kept my eyes peeled for a language which could help me take my career to the next level the way Ruby had. As a dynamic, interpreted language, Ruby never quite met my performance standards. It was fast enough to handle simple API requests on a small scale, but due to MRI Ruby’s use of a GIL, concurrency was a pain in the ass to even attempt, let alone accomplish.
As I began to venture into managing backend systems and architecture, command-line tools and scripts were frequently needed to be created. Ruby was okay for building tooling, but again — too slow. Statically-compiled languages (like C and Java) never made much sense to me. Attempts to build something simple would result in me throwing my hands in the air, shouting, “This is just too complex!” — especially after being spoiled rotten with Ruby, my first true love!
Things changed while I was working at Rovi back in 2013 when Go was recommended to me in passing for a certain tool I was trying to build. I figured I would give it a try. For the first time since Ruby had won my heart, I felt a spark! I wrote my first tool in a compiled language and put it into production that day. I couldn’t contain my excitement, and desperately sought out more reasons to use Go.
Sadly, it was not until just a few months ago while working at HotelTonight that I would get a chance to build out production-quality tools in my newly beloved language again. I was able to build a few pretty handy CLI tools:
- ht-load-test — enables engineers to quickly and easily run performance benchmarks on any API endpoint. Prior attempts to build such a tool using JRuby had required many external dependencies to be downloaded, installed and configured(Apache JMeter, some Ruby gems, etc), whereas now one must simply download a single binary from GitHub, or alternatively, simply run it from a Docker container.
- ht-db-clone — creates a new Amazon RDS database instance from the most recent production database snapshot. Once it becomes available, it runs required Rake tasks to clean/generate data. Finally, it optionally updates a given Amazon Route 53 SRV resource record set for the updated database instance hostname.
For me, Go has proven itself to be my go-to language when building tooling like this because it is easy to pick up and run with. The HT engineering team were all pretty impressed by the rapid development turnaround time.
I think it is time to face the truth…
I ❤ Go!
After only about four-to-six months of solid production-level Go experience, I feel it may be a tad premature for me to offer a significant amount of advice to anyone who may want to try this awesome language out themselves. Over time as I become more familiar with the intricacies of developing with Go, I will curate best practices and blog about them.
For now, though, here are some things I’ve found or learned that may help new developers:
- Go expects developers to stick to community conventions. Adhering to the naming guidelines will ensure new developers will have a solid grounding when they are onboarded to an existing project.
- Reading the tests of an external package on GitHub can help you understand fastest. For example: look at how to make a POST request with the standard Go net/http client package.
- The Go community is fresh, and grows every day. There are excellent community-generated resources such as the curated awesome-go list (similar to Ruby Toolbox), as well as official help channels via IRC, the mailing list, and more. Get the latest news about Go at Reddit via /r/golang, or Twitter via @golang. Read books about Go, find a sweet new job to show off all your new skills… I could go on.