View : 110

21/11/2026 00:00am

Two-sided diagram comparing Go, which uses a garbage collector, with Rust, which manages memory through ownership

Rust vs Go: Memory, Error Handling and Concurrency Compared for Developers Who Already Write Go

#Rust

#Golang

#Rust vs Go

#Garbage Collector

#Concurrency

#Goroutine

When Go developers on our team's radar ask, "I would like to try Rust. Where do I start, and how different is it from Go?", the answer we give most often is this: both languages compile to programs that run natively, but they take very different positions on three important decisions. Who looks after memory, how hard errors are forced into view, and how concurrency is made safe.

Today Superdev Academy compares those three topics one by one, relying on each language's official documentation. We do not quote benchmark numbers, because results depend on the workload and the machine. At the end there is guidance on choosing by type of work, which is our own opinion rather than a fact from the docs, and we will mark it clearly when we get there.

Topic 1: Who looks after memory?

Go: let the garbage collector handle it

Go has its runtime reclaim memory that is no longer used. The official A Guide to the Go Garbage Collector explains that Go's GC uses the mark-sweep technique, is non-moving, and does most of its work concurrently with the application rather than being fully stop-the-world. As a result we almost never think about freeing memory, and we pay with the CPU and memory the runtime spends on collection.

The same guide describes two knobs. The first is GOGC, which sets the heap target with the formula live heap plus GC roots, multiplied by GOGC over 100. The effect is direct: doubling GOGC doubles the heap memory overhead and roughly halves the GC's CPU cost. The second is GOMEMLIMIT, introduced in Go 1.19, a soft limit on the total memory the runtime may use. The guide warns that a limit set too low causes thrashing, so the runtime caps GC CPU at roughly 50% and lets memory exceed the limit to avoid it.

Rust: no GC, ownership decided at compile time

Rust has no garbage collector and does not ask you to free memory by hand. Instead the compiler checks the Ownership rules at compile time: each value has exactly one owner, and when the owner goes out of scope the value is released immediately. Our article on Rust Ownership covers the rules in detail. What you pay is that you must understand borrowing and lifetimes from day one, and the compiler rejects code that breaks the rules even if that code might have run correctly in some cases.

In practice, the memory question in Go usually looks like "how should I tune GOGC or GOMEMLIMIT?", while in Rust it moves to the moment you write the code: who owns this value, and who can borrow it for how long? Both have a cost; they are simply paid at different times.

Topic 2: How hard are errors forced into view?

Neither language uses exceptions as the main mechanism for ordinary errors, but the way each language makes errors visible is different.

Go treats an error as an ordinary value. The official blog post Error handling and Go explains that error is an interface with a single method, Error() string. A function that fails returns a non-nil error, and the caller checks it with the if err != nil pattern every Go developer knows.

data, err := os.ReadFile("config.txt")
if err != nil {
    return err
}
// data is usable from here

On the Rust side, the official book separates errors into two kinds: recoverable errors, which use the type Result<T, E>, and unrecoverable errors, which use the panic! macro. The book says Rust has no exceptions, and in many cases it requires you to acknowledge the possibility of an error and do something about it before your code will compile. An example comparable to the Go code above:

use std::fs;
use std::io;

fn read_config() -> Result<String, io::Error> {
    let data = fs::read_to_string("config.txt")?;
    Ok(data)
}

The ? operator does a job similar to if err != nil { return err } in Go: on Ok you get the inner value and continue, on Err the function returns that error immediately. The difference lives in the type system. Result is an enum that match must handle exhaustively, and the T inside cannot be reached until it has been checked. In Go the compiler does not stop you from leaving an err unchecked (by assigning it to _ or calling a function and ignoring its return value). Linters can catch that, but it is not a rule of the language.

Topic 3: How is concurrency designed differently?

Go: goroutines and channels are built into the language

Effective Go defines a goroutine as a function executing concurrently with other goroutines in the same address space. It is lightweight, costing little more than the allocation of stack space; stacks start small and grow as needed. Goroutines are multiplexed onto multiple OS threads, so if one blocks while waiting for I/O, the others keep running. You start one by putting go in front of a function call.

ch := make(chan string)
go func() { ch <- "hi" }()
fmt.Println("Got:", <-ch)

The same document gives the language's motto, "Do not communicate by sharing memory; instead, share memory by communicating", and adds that the approach "can be taken too far", for example a reference count may be best done by putting a mutex around an integer variable. (Effective Go was written for Go's 2009 release and is not actively updated, but the principle still holds.)

Rust: the type system checks concurrency at compile time

The Fearless Concurrency chapter of the Rust book says the team found that the ownership and type systems are a powerful set of tools for managing memory safety and concurrency problems, so many concurrency errors become compile-time errors rather than runtime errors. Incorrect code will refuse to compile and present an error explaining the problem. Here is an example of sending a message between threads over a channel:

use std::sync::mpsc;
use std::thread;

fn main() {
    let (tx, rx) = mpsc::channel();

    thread::spawn(move || {
        tx.send(String::from("hi")).unwrap();
    });

    let received = rx.recv().unwrap();
    println!("Got: {received}");
}

The book also leaves room to choose the model that fits the problem: threads, message passing with channels, shared state, and the Send and Sync traits that extend the guarantees to types you define. The first thing people coming from Go usually run into is async. The Rust book explains that async code needs third-party crates that implement asynchronous runtimes, which manage and coordinate the execution of async operations. In Go, the goroutine scheduler is already part of the language and its runtime.

That is why people often say concurrent code is easier to write in Go at first, while Rust pays its complexity up front so the compiler can check more. We see it as a trade-off to weigh per project, not a case where one side wins outright.

So which should you pick? (our team's opinion)

This section is our own opinion. It does not come from either language's documentation and is not backed by measurements, so use it only as one input to your decision.

  • If your work is an API or ordinary backend service where the team needs to ship quickly, people join and leave often, and the latency a GC adds is acceptable, Go is often the more direct fit.

  • If your work needs fine control over memory use, needs to avoid a GC in time-sensitive parts, or you want the compiler to check concurrency and errors more strictly, Rust is worth considering, at the price of a longer learning curve.

  • If a team has both, Go for general services and Rust for specific components is workable, but count the cost of maintaining two languages.

If you are still unsure about starting Rust, read Why Rust?, or go back to the Go side in the Golang The Series to compare with what you use today.


Summary: both languages charge you, just at different times

Go lets the runtime look after memory, makes errors ordinary values you check yourself, and gives you goroutines that are easy to use from day one. Rust has no GC, decides ownership at compile time, forces you to acknowledge errors through Result, and uses the type system to check concurrency in advance, in exchange for more rules to learn early on.

The question to ask before choosing is therefore not which language is better, but where your work hurts more: the latency and memory a GC consumes, or the time your team spends learning the compiler's rules. If you cannot answer yet, write the same small service in both languages over one free day and notice when you are less frustrated. That answer often says more than any comparison table.

🎯 Follow dev knowledge from Superdev Academy:

FAQ: Frequently Asked Questions about This Article

A collection of questions and answers to help you better understand the content of this article.