Rust Versus Go

Which Is My Preferred Language?

Mike Riley
The Pragmatic Programmers
4 min readJul 1, 2022

--

https://pragprog.com/newsletter/

After having learned these languages from fellow Pragmatic Bookshelf author’s books, I have been using both Rust and Go throughout this past year.

Herbert Wolverson’s Hands-on Rust:

Ricardo Gerardi’s Powerful Command-Line Applications in Go:

Having been asked by co-workers and peers throughout the year, the big question that seems to come up in Medium articles and Reddit Rust and Go forums is, “Which one is better?” There’s really no answer to that question since its such a subjective decision. Nearly all of these articles and posts conclude with, “It depends.” But that’s not a satisfactory answer given how engineers prefer absolute binary decisions. So a better question is, “Which one do you prefer?” Having used both languages in various scenarios, my default go-to language is… Go.

Why Go?

I am not a systems programmer and spend most of my day working on DevOps-related efforts. Go was made for DevOps, as is evident with all the DevOps-centric apps like Docker, Grafana, and Kubernetes. I also don’t have the patience for long compiles only to find the build failed due to some obtuse error that takes me sometimes hours to figure out. And as those who have read my latest book or heard me interviewed on a recent Changelog podcast know, I use Raspberry Pi’s extensively throughout my home. Try compiling a Rust app longer than “Hello, World!” on a Pi Zero. If you’re lucky, it will be done in an hour or more, assuming no compile errors crop up.

Yes, Go does carry around an embedded runtime with each executable, but it’s relatively small compared to the overall benefits of compile speed and portable convenience. And while both languages carry around boatloads of dependencies, it seems in recent months that Rust has become a larger target for supply chain attacks, perhaps due to its growing prominence in the community as it is admitted into the Linux kernel. Companies like System76 have also said they intend to use Rust to build out their Pop!OS desktop.

Performance

In terms of performance, I found — for my meager projects — that both perform similarly. I am not building massive parallel petabyte-size architectures, but rather small, stable programs that do one particular task well.

If I want to keep things simple and don’t care about performance, a Python script will do just fine. But if I want a bit more performance and a single, fairly small native executable, Go is my primary language of choice these days. Sure, there’s no official GUI support in the language, but the same is true for Rust. And while Webkit-based GUI projects exist for both languages, neither of them interest me enough to learn them.

Command Line Programs

In fact, thanks to the nature of their terminal-centric output, these languages have allowed me to rediscover the joy and speed of un-bloated command-line iterative programs. For example, I wrote a custom Twitter client in Go that highlights in different colors key hashtags and people that I follow, allowing me to quickly and visually identify posts of interest in my feed. It uses Redis cloud on the backend so that each time I run tw, it maintains sync across the variety of OS’s I run it on. It took me less than an hour to write in Go, and less than a few seconds to compile even on my Pi Zero. While I did toy with the idea of re-writing it in Rust just to practice my language chops, time continues to march onward and there are only so many hours in a day to spend on learning and experimentation.

Does Rust Stand a Chance?

If and when Rust can reduce the compile times to a more reasonable duration, and provide less obtuse error messages when compiles break, I may return to re-evaluate my primary language choice. But for now, Go is at the top of my coding list when I need to create and deploy new programs quickly.

📢 Share your experience by leaving a comment. What language do you prefer, and why?

Be sure to pick up a copy of Portable Python Projects by Mike Riley, available from The Pragmatic Bookshelf. You can save 35 percent with promo code python_automation_2022 now through July 30, 2022. Promo codes are not valid on prior purchases.

Gopher by Renee French, CC 3.0, via Wikimedia Commons
https://creativecommons.org/licenses/by/3.0
Rust mascot by Karen Rustad Tölva, CC0, via Wikimedia Commons
https://commons.wikimedia.org/wiki/File:Rustacean-flat-gesture.svg

--

--