Rust vs Go in 2024 — Bitfield Consulting (2024)

Which is better, Rust or Go? Which language should you choose for your next project, and why? How do the two compare in areas like performance, simplicity, safety, features, scale, and concurrency? What do they have in common, and where do they fundamentally differ? Let’s find out, in this friendly and even-handed comparison of Rust and Golang.

As it happens, I teach (and write about) both Go and Rust professionally, and I’m also a keen user of both languages, which I suspect makes me something of an outlier: I’ve got a foot in both camps! Since there can be a fair amount of perfectly understandable tribal feeling about one’s favourite programming language, maybe it’ll be helpful to get a new perspective, from someone who loves both Rust and Go. Here’s why.

Rust and Go are both awesome

First, it’s really important to say that both Go and Rust are absolutely excellent programming languages. They’re modern, powerful, widely-adopted, and offer excellent performance.

Rust is a low-level statically-typed multi-paradigm programming language that’s focused on safety and performance.

Gints Dreimanis

Whereas:

Go is an open-source programming language that makes it easy to build simple, reliable, and efficient software.

golang.org

In this article, I’ll try to give a brief overview of where I think Go is the ideal choice, and where I think Rust is a better alternative.

Similarities

What are some of the common goals of both languages?

Memory safety

Historically, one of the biggest causes of software bugs and security vulnerabilities has been accessing memory unsafely or incorrectly.

Rust and Go deal with this problem in different ways, but both aim to be smarter and safer than other languages about managing memory.

The genius of Go is that it has a garbage collector. The genius of Rust is that it doesn’t need one.

Fast, compact executables

They’re both compiled languages, which means your programs are translated directly to executable machine code, so that you can deploy your program as a single binary file. This also makes both Rust and Go programs extremely fast in comparison to interpreted languages such as Python or Ruby.

General-purpose languages

Rust and Go are also both powerful, scalable general-purpose programming languages, which you can use to develop all kinds of modern software. Both have excellent standard libraries and a thriving third-party ecosystem, as well as great commercial support and a large user base.

Pragmatic programming style

While both Go and Rust have features associated with functional and object-oriented programming (OOP), they’re pragmatic languages aimed at solving problems in whatever way is most appropriate.

Development at scale

Both Rust and Go have some useful features which make them suitable for programming in the large, whether that means large teams, or large codebases, or both.

For example, both Rust and Go use a standard code formatting tool (gofmt for Go, rustfmt for Rust), putting an end to useless arguments over where to put your brackets.

Both also have excellent, built-in, high-performance standard build and dependency management tools; no more wrestling with complex third-party build systems and having to learn a new one every couple of years.

Differences

While Rust and Go have a lot in common, there are also a few areas where a reasonable person might prefer one language over the other, to meet the specific needs of their project.

Performance

Both Go and Rust are very fast. However, while Go’s design favours fast compilation, Rust is optimised for fast execution.

Rust’s run-time performance is also more consistent, because it doesn’t use garbage collection. On the other hand, Go’s garbage collector takes some of the burden off the programmer, making it easier to focus on solving the main problem, rather than the fine detail of memory management.

Rust is a better choice for areas where speed of execution beats all other considerations, such as game programming, operating system kernels, web browser components, and real-time control systems.

Simplicity

Go is a small language, by design: it has very little syntax, few keywords, and as few language constructs as it can get away with. You can learn the basics of Go and be productive in the language very quickly.

That gives Go the advantage in projects with a short timescale, or for teams that need to onboard lots of new programmers quickly, especially if they’re relatively inexperienced.

On the other hand, the very simplicity of Go means that you need to write more code to solve certain problems: the language does less of the heavy lifting for you. It also doesn’t suit some programmers who like a very rich, expressive language that gives them many different ways to solve a problem.

Features

At the other end of the scale, Rust has just about every feature you could imagine in a programming language, and some you probably can’t. That makes it a powerful and expressive language, with lots of different ways to do the same thing.

If you’re transitioning to Rust from some other language, you can probably find Rust equivalents for most of the features you’re used to. That gives Rust the advantage when large projects need to be migrated from a traditional language such as C++ or Java.

On the other hand, the complexity of Rust, and the new way of thinking about problems that it requires, makes experienced Rust developers expensive, and it can take longer to ramp up junior developers to a level where they can be productive. Rust might not be the best choice for projects that need very rapid development or prototyping, or where cost is a bigger factor than safety and reliability.

To summarise:

Go is too simple to write complicated programs, while Rust is too complicated to write simple programs. It all depends which problem you’d rather have.

Concurrency

Unlike most languages, Go was designed with built-in features for concurrent programming, such as goroutines (a lightweight version of threads) and channels (safe and efficient ways to communicate data between concurrent tasks).

These make Go the perfect choice for high-scale concurrent applications such as webservers and microservices.

Safety

Rust is carefully designed to ensure that programmers can’t do something unsafe that they didn’t mean to do, such as overwriting a shared variable. The compiler requires you to be explicit about the way you share data between different parts of the program, and can detect many common mistakes and bugs.

As a result, so-called “fighting with the borrow checker” is a common complaint among new Rust programmers. Implementing your program in safe Rust code often means fundamentally re-thinking its design, which can be frustrating, but the benefits can be worth it when reliability is your top priority.

Scale

Go was designed to make it easy to scale both your projects and your development teams. Its minimalist design leads to a certain uniformity, and the existence of a well-defined standard style means that any Go programmer can read and understand a new codebase relatively quickly.

When it comes to software development in the large, clear is better than clever. Go is a good choice for big organisations, especially with many distributed teams. Its fast build times also favour rapid testing and deployment.

Trade-offs

Rust and Go’s design teams have made some starkly different choices, so let’s look at some areas where those trade-offs make the two languages very distinct from one another.

Garbage collection

Languages (like Go) that feature garbage collection, and automatic memory management in general, make it quick and easy to develop reliable, efficient programs, and for some people that’s the most important thing.

But garbage collection, with its performance overhead and stop-the-world pauses, can make programs behave unpredictably at run-time, and some people find this inconsistency unacceptable.

Languages (such as Rust) where the programmer must take explicit responsibility for allocating and freeing every byte of memory, are better for real-time or ultra-high-performance applications.

Error handling

In some languages, when a function encounters an error (for example, something like “file not found”), it can be handled explicitly, or it can be automatically propagated back to the function’s caller, and the caller’s caller, and so on, until it either finds someone willing to handle the problem, or the program crashes with an ugly error message.

Errors that trigger an automatic return from the function if not handled are called exceptions, and, while convenient for programmers, can lead to some confusing behaviour—especially if the exceptions are used deliberately as a control flow mechanism.

In both Rust and Go, while exceptions are available, their use is strongly discouraged. Instead, Go lets the programmer choose to either ignore a possible error, or explicitly check and return it (perhaps with some added context, via the error wrapping feature).

Rust’s error handling is even more powerful, relying on built-in Option and Result types which indicate that a return value may or may not be present, or may instead be some error. If a function returns Result, for example, its return value can’t be used directly: Rust’s strict type system forces you to specify what should happen instead if there’s an error.

However, Rust also provides a neat syntactic shorthand: the ? operator causes a function to return automatically if the Option value is not present, or the Result value contains an error. Since errors happen a lot, this gives Rust programmers a more compact way to write the necessary handling code than is available in Go.

Abstraction

The history of computer programming has been a story of increasingly sophisticated abstractions that let the programmer solve problems without worrying too much about how the underlying machine actually works.

That makes programs easier to write and perhaps more portable. But for many programs, access to the hardware, and precise control of how the program is executed, are more important.

Rust aims to let programmers get “closer to the metal”, with more control, but Go abstracts away the architectural details to let programmers get closer to the problem.

The key difference between Rust and Go: you think you can understand Go code, but you’re wrong. On the other hand, you think you CAN’T understand Rust code, and you’re right.

Speed

Rust makes a number of design trade-offs to achieve the best possible execution speed. By contrast, Go is more concerned with simplicity, and it’s willing to sacrifice some (run-time) performance for it.

Whether you favour Rust or Go on this point depends on whether you spend more time waiting for your program to build, or waiting for it to run.

Correctness

Go and Rust both aim to help you write correct programs, but in different ways: Go provides a superb built-in unit testing framework, for example, and a rich standard library, while Rust is focused on eliminating run-time bugs using its borrow checker.

It’s probably fair to say that it’s easier to write a given program in Go, but the result may be more likely to contain bugs than the Rust version. Rust imposes discipline on the programmer, but Go lets the programmer choose how disciplined they want to be about a particular project.

What now?

I hope this article has convinced you that both Rust and Go deserve your serious consideration. You should reject the false dilemma that you can only learn one or the other. In fact, the more languages you know, the more valuable you are as a software developer.

If you’re new to the tech industry, getting some skills in one or both of these two languages should be your priority. If you’re an established developer who doesn’t yet have Go or Rust on your resume, I think you’d be well advised to invest some time in acquiring them. Legacy languages such as C++, Python, Java, and friends will still be around for years to come, no doubt—that’s what “legacy” means—but they wouldn’t be the first things I’d pick up. New development in many large companies is now restricted to memory-safe languages only, which effectively means either Go or Rust, and probably the latter.

Every new language you learn gives you new ways of thinking about problems, and that can only be a good thing. The most important factor in the quality and success of any software project is not the choice of language, but the skill of the programmer. You will be most skilful when using the language that suits you best, and that you enjoy programming in the most. So, if the question is “Should I learn Rust or Go?”, the only right answer is “Yes.”

More resources

Check out my selections of the best Rust books and the best Go books, and you’ll find plenty of fantastic learning materials. If you’d like to take your journey further, you might like to consider studying either Rust or Go with me, in personal, one-to-one coaching and mentoring sessions. Contact me if you have any questions—I’ll be happy to chat with you.

Rust vs Go in 2024 — Bitfield Consulting (2024)

FAQs

Rust vs Go in 2024 — Bitfield Consulting? ›

Both Go and Rust are very fast. However, while Go's design favours fast compilation, Rust is optimised for fast execution. Rust's run-time performance is also more consistent, because it doesn't use garbage collection.

Should I learn Golang or Rust in 2024? ›

Conclusion. At the end of the day, both Rust and Go are great choices when it comes to building server-side applications. However, the correct choice will be based on the requirements of your application and what you want to achieve.

Which is better, Rust or Go? ›

Rust, from Mozilla, prioritizes memory safety and performance, making it great for systems programming. Go is simpler, Rust offers more control. In performance, Go is efficient; Rust balances memory safety and performance. According to Stack Overflow, 13.24% use Go, while 84.66% admire Rust.

When to choose Go over Rust? ›

Go is an excellent choice if you're starting a new project or refactoring an existing codebase. Rust: It fails to offer smooth code maintenance mainly because of its steep learning curve. The language has a lot of concepts that developers need to learn before they can even start writing applications in it.

Will Rust replace Golang? ›

Go and Rust are different programming languages that serve different purposes and are used in different ways. It seems unlikely that either will replace the other.

Is learning Rust worth it in 2024? ›

Learning Rust in 2024 is worth it. Rust has continued to gain traction and recognition in the programming community due to its unique blend of performance, safety, and modern language features.

Is Go still popular in 2024? ›

Recently, there's been a noticeable uptick in interest surrounding the Go programming language. So, what's behind this surge? Let's delve into the factors contributing to Go's increasing popularity as of 2024. Stackoverflow-Most used programming languages by professional developers.

Is Rust more difficult than Go? ›

Becoming productive with Go is much easier and takes less time than becoming productive with Rust. Many developers find it harder to understand Rust — especially its memory safety rules, type conversions, and type checks.

Is Rust losing popularity? ›

Rust is growing in popularity, but it still has some way to go. The research on Rust's growing popularity as a programming language aligns closely with similar analysis from Stack Overflow's 2023 developer survey.

Is Rust programming language dying? ›

According to the Stack Overflow Developer Survey, Rust ranks as the most loved programming language for the eighth consecutive year. Rust is One of the Fastest Growing Programming Languages, According to The IEEE Spectrum Development report by Tiobe Co.

Should I learn Rust or Go first? ›

If you want to do systems programming, especially want to do kernel hacking, Rust would be better over Go, because you'd have to deal with GC if you choose Go. I would start with Go for more general programming and would play with Rust along the way to see it is worth the switch.

Should I use Rust for microservices? ›

With its support for concurrency, Rust suits modern apps and microservices. It provides type-level guarantees for values that can be shared simultaneously between threads.

Is Rust outdated? ›

Restricting programmers of what they can or cannot use, Rust doesn't have decent inheritance and exceptions, making it simple yet interfering with the availability of programming paradigms among the programmers. No doubt, Rust's popularity started declining from the year 2018.

Is Golang worth learning in 2024? ›

In conclusion, Golang is a smart choice for businesses looking to stay ahead in 2024. It's fast, easy to learn, and reliable, making it a great tool for growing your business. With companies like Uber and Dropbox already seeing success with Go, it's clear this language has a lot to offer.

Is Golang losing popularity? ›

Go is once again the world's 10th most popular programming language, per the March 2023 edition of the Tiobe index. Google's Go language has re-entered the top 10 of the Tiobe index of programming language popularity, after a nearly six-year absence.

Does Rust have any future? ›

Rust also has some plus points when it comes to building ML and AI applications that deal with complex data structures or do efficient memory management. In the Future There Will Be More Libraries And Toolkits Utilized For Rust That Are Intended For Scientific Computation Or Deep Learning Computation.

Which programming language should I learn in 2024? ›

Best Programming Languages to Learn For Your Career Goals

Front-end web development: JavaScript, TypeScript, CSS. Back-end web development: JavaScript, TypeScript, Python, Go, Ruby, Scala. Mobile development: Swift, Java, C#

How popular is Rust 2024? ›

Monthly number of peak concurrent players of Rust on Steam worldwide as of July 2024 (in 1,000s)
CharacteristicNumber of players in thousands
2024-02153.74
2024-01190.89
2023-12143.04
2023-11137.75
9 more rows
Aug 6, 2024

Is there a future for Golang? ›

Yes, Golang offers a promising career path. The growing demand and its focus on concurrency make it a valuable skill for developers. The active Golang community and abundant resources further support your career growth.

Top Articles
Gardenscapes Revenue and Usage Statistics (2024)
USCIS Contact Center | USCIS
Ffxiv Shelfeye Reaver
Euro (EUR), aktuální kurzy měn
The Ivy Los Angeles Dress Code
Undergraduate Programs | Webster Vienna
Gore Videos Uncensored
DENVER Überwachungskamera IOC-221, IP, WLAN, außen | 580950
What Auto Parts Stores Are Open
Bernie Platt, former Cherry Hill mayor and funeral home magnate, has died at 90
South Ms Farm Trader
Brenna Percy Reddit
fltimes.com | Finger Lakes Times
New Mexico Craigslist Cars And Trucks - By Owner
8 Ways to Make a Friend Feel Special on Valentine's Day
Sams Early Hours
Busted Newspaper S Randolph County Dirt The Press As Pawns
Bcbs Prefix List Phone Numbers
Letter F Logos - 178+ Best Letter F Logo Ideas. Free Letter F Logo Maker. | 99designs
Fdny Business
Razor Edge Gotti Pitbull Price
Billionaire Ken Griffin Doesn’t Like His Portrayal In GameStop Movie ‘Dumb Money,’ So He’s Throwing A Tantrum: Report
Sound Of Freedom Showtimes Near Cinelux Almaden Cafe & Lounge
Sprinkler Lv2
Heart Ring Worth Aj
Craigslist Houses For Rent In Milan Tennessee
Certain Red Dye Nyt Crossword
4 Methods to Fix “Vortex Mods Cannot Be Deployed” Issue - MiniTool Partition Wizard
Wolfwalkers 123Movies
Login.castlebranch.com
Keshi with Mac Ayres and Starfall (Rescheduled from 11/1/2024) (POSTPONED) Tickets Thu, Nov 1, 2029 8:00 pm at Pechanga Arena - San Diego in San Diego, CA
Mobile crane from the Netherlands, used mobile crane for sale from the Netherlands
25Cc To Tbsp
Gina's Pizza Port Charlotte Fl
Vistatech Quadcopter Drone With Camera Reviews
Chattanooga Booking Report
Weekly Math Review Q4 3
Blue Beetle Movie Tickets and Showtimes Near Me | Regal
Wsbtv Fish And Game Report
Mydocbill.com/Mr
Dinar Detectives Cracking the Code of the Iraqi Dinar Market
Arigreyfr
Linkbuilding uitbesteden
Gotrax Scooter Error Code E2
'The Nun II' Ending Explained: Does the Immortal Valak Die This Time?
Mauston O'reilly's
877-552-2666
How to Do a Photoshoot in BitLife - Playbite
How Did Natalie Earnheart Lose Weight
Craigslist Yard Sales In Murrells Inlet
Turning Obsidian into My Perfect Writing App – The Sweet Setup
Bob Wright Yukon Accident
Latest Posts
Article information

Author: Ms. Lucile Johns

Last Updated:

Views: 5816

Rating: 4 / 5 (61 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Ms. Lucile Johns

Birthday: 1999-11-16

Address: Suite 237 56046 Walsh Coves, West Enid, VT 46557

Phone: +59115435987187

Job: Education Supervisor

Hobby: Genealogy, Stone skipping, Skydiving, Nordic skating, Couponing, Coloring, Gardening

Introduction: My name is Ms. Lucile Johns, I am a successful, friendly, friendly, homely, adventurous, handsome, delightful person who loves writing and wants to share my knowledge and understanding with you.