Why I Chose Golang Over Rust

In 2019 I was looking for a new, modern programming language to replace Java as my main language. I needed to rewrite an interpreter in a faster programming language as Java wasn’t quite working any more. My options were Rust, Go and Swift, from which I shortlisted Rust and Go.

I left Swift out of my list because it was the youngest of the three, and not as mature.

After trying Rust and Go, I decided for Go because of its simplicity, maturity, rich ecosystem of libraries, projects and tools, and for the fact that it is backed by Google and has Ken Thompson’s involvement.

Go and Rust are very similar languages. Both are excellent languages. However, Rust has a steep learning curve, while Go has a simple syntax that makes learning the language easier. Both support more or less the same concepts, but they have different use cases. Go targets application programmers, while Rust targets system programmers. Go’s syntax is so simple that, in less than two weeks, I was able to put together a fully-functional Go backend for SableCC. This, obviously, because I am familiar with the languages that inspired its creation. Both Rust and Go are memory safe languages. Although Rust is quite picky with regards to memory management. Go uses garbage collection, which makes it safe, but slow at run-time, although in Go 1.18 the runtime is expected to be 15% faster. Rust is faster at run-time, but slower at compiling. Go’s code is compiled in a much, much faster time.

Getting the first point out of the way, the second factor in my decision was Go’s maturity and the fact that it is backed by Google. While the first stable release of Rust was in 2015, Go’s stable release was in 2011. Although it may not seem much, in 4 years one can develop a lot with a stable language and compiler tools. Rust was initially backed by Mozilla, but due to financial restrictions ended up withdrawing from the project in 2021. Rust is now managed by a non-profitable organization: the Rust Foundation.

One of the things that grabbed my attention to Go was its rich ecosystem of libraries and the tools that allow one to accelerate the development process. It has godoc for documentation, gofmt for code formatting and glint for code style listing. Furthermore, you have libraries for just about anything. From network programming, to parser generation, to web development. Rust also has all of these, but Go has far more. In addition to these, there are other popular tools that were developed using Go. Among them is the static site generator Hugo, that I use to power all my blogs.

The main goal of Go was to be able to develop and compile faster. In fact, when developing a new project one should focus on making it functional first, and then optimize it. This has been the motto behind the Go compiler. Now that it is pretty functional, they have began to address the runtime efficiency, and although it is yet appropriate for operating systems development, one day it may be.

In conclusion, I think both languages are great. However, Go is much simpler, more mature and has a faster development cycle. Rust produces faster code, but Go compiles faster. Rust was developed for systems programming, while Go was develop for faster application development. Any language can be used for any purpose, although Go is not appropriate for operating systems development, but it can be used for other systems programming such as compiler writing. In fact, the Go compiler is written in Go.

I hope that sharing my reasons for choosing Go versus Rust has helped you get a different viewpoint when it comes to choosing one of the two. Furthermore, if you have any comments, please do so on my social media channels. I’d like to hear from you, learn from your experience.

Related Posts:

  • The Struct Embedding Trap in Go Go is a programming language that uses composition over inheritance. Yet, it provides a feature known as Struct Embedding that abstracts this, and makes it seem as if Go supports inheritance, leading us to make wrong assumptions and fall into a trap I’ll demystify in this article. Particularly for those coming from an object-oriented language like Java. Read More
  • Chandler Carruth Announces Carbon Chandler Carruth just announced today a new programming language called Carbon, an experimental language that is supposed to be the successor of C++. Read More