If you were to make a list of important programming languages that have appeared in the past decade, Go and Rust would almost certainly be featured on it.

Similarly, if you were to sit down and think about which programming languages are best suited to developing secure, microservices-friendly frameworks or applications today, you might find yourself debating between Go and Rust.

If you’re struggling to decide whether Go or Rust is a better language for your development needs, keep reading. This post compares Go and Rust, explaining how they are similar, how they’re different, and what each can do for you.

The Go programming language
Introduced to the public in 2009, Go (which is also known as Golang) was designed by Google engineers (including Ken Thompson, of Unix fame). There were various motivations behind the creation of Go, but the developers’ goals can perhaps be summed up by saying simply that they wanted a language that offered the efficiency of C++ but that was easier to write, read and deploy in an optimized way on multi-core CPUs.

Toward that end, one of Go’s distinguishing features is the goroutine, which makes it easy to define functions that run as distinct subprocesses. By taking advantage of goroutines, developers can easily build applications in Go that take full advantage of concurrency by deploying workloads across multiple CPU cores at the same time.

Concurrency and optimization are powerful features. They’re part of the reason why we chose to develop Twistlock using Go.

The Rust programming language
The history of Rust parallels that of Go in many ways. Rust was born as a personal project of a Mozilla engineer that started in the mid-2000s. The language became publicly available in 2010.

Like Go, Rust was motivated in part by a desire to improve upon the conventions of C++, including by making it easier to implement concurrency. Doing so in a way that does not compromise security was also a primary consideration. Toward that end, Rust makes it very difficult for developers to introduce flaws into code that could lead to buffer overflows or other memory-related vulnerabilities.

What Go and Rust have in common
In many ways, Go and Rust are similar. They’re both among the youngest programming languages to be widely used today. (Most of today’s other popular languages, like C, Java and Python, are considerably older.)

Go and Rust are compiled languages, both are open source, and both are designed for modern, microservices-oriented, parallel computing environments.

And they’re both easy to learn if you already know C++.

Go vs. Rust
This may leave you wondering, “Should I use Go or Rust to develop my next application?”

There are a lot of ways to approach answering that question, but I’d recommend thinking about it in terms of what type of application you are building. For my money, Go caters to a broader set of use cases, and is somewhat more flexible. Go makes it very easy to build a nicely factored application that takes full advantage of concurrency while being deployed as a set of microservices.

Rust can do those things, too, but it’s arguably a bit tougher. In some respects, Rust’s obsession with preventing memory-related security vulnerabilities means that programmers have to go out of their way to perform tasks that would be simpler in other languages, including Go.

Note that this does not mean that Go is insecure, by the way. Go is as secure as any other modern programming language. It just doesn’t obsess about security in the same way that Rust does, or allow security to take priority over broader functionality.

In short: Rust is somewhat harder to work with, and is more oriented toward building applications with a narrow scope where security is the only thing that really matters. In contrast, Go is ideal for building applications where you are concerned not only about security, but also a variety of other factors — which is probably your goal if you are a DevOps team that aims to build a flexible, extensible application or framework.

It’s worth noting, too, that Go is considerably more popular among developers today. The TIOBE Index ranks Go as the 15th most-popular programming language, while Rust sits in 34th place. I know your mother told you that you shouldn’t do something just because everyone else is, but in the world of programming, there are real benefits to choosing languages that are more popular. Other programmers are more likely to know them, which makes it easier to share code or add members to your team. Popular languages also tend to have better community support, documentation and plugins.

If it sounds like I’m hesitant to make a definitive recommendation regarding whether to use Go or Rust, it’s because I am. Both are great, modern languages, and you would do well to consider both when deciding how to build a new application.

That said, I, like a majority of programmers, tend to lean a bit more toward Go, generally speaking, because it caters to a broader set of use cases while still providing a high level of security and performance.