Go vs Rust: The Problems Each One Really Solves

Table of Contents
Reading Progress
0%

A few years ago I had to pick a language for a service that ingested events from about forty devices per second, wrote them to a database, and occasionally did some number crunching on the way through. Two candidates were on the table: Go, which my team already knew, and Rust, which two very enthusiastic colleagues kept mentioning in every retro.

I picked Go. It shipped in two weeks and never gave us trouble.

Then a year later I had a different problem: a CSV parser that chewed through four gigabytes of billing exports every night, and the Go version kept the machine at 100% CPU for fifty minutes while the finance team waited. I rewrote the hot part in Rust. It finished in eleven minutes. That was the right call too.

That is the honest shape of this comparison. Neither language won. The problems were different, and so were the answers. Most “Go vs Rust” articles turn into a fight about which one is better, which is a bit like arguing whether a hammer or a screwdriver is the better tool. So let me write the version I wish I had read back then.

The short version, before the nuance

If you only have thirty seconds:

Go is a language for people who need to ship networked services and keep them running. Small language, fast builds, goroutines, garbage collection, and a standard library that already contains an HTTP server, a JSON encoder, and testing. You spend your time on the product, not on the type system.

Rust is a language for people who need maximum performance with no garbage collector, or who need to be sure that memory bugs cannot exist. Ownership and the borrow checker move a whole class of bugs from runtime to compile time. You pay for it with a steeper learning curve and slower builds.

Both compile to a single native binary. Both are fast. Both have excellent tooling. Neither is a toy.

What each language is actually optimising for

This is the part people skip, and it explains every other difference.

Go optimises for reading code at 3 p.m. on a team of twelve. The language is deliberately small. There is one obvious way to write a loop, one way to handle an error, one formatter, one test runner. A new hire can read production code on day one. Go’s designers gave up a lot of expressive power to get there. No operator overloading, no inheritance, no macros, no exceptions. Every one of those decisions makes the language less fun for language enthusiasts and more predictable for a team.

Rust optimises for correctness and control. It gives you expressive power and then makes the compiler enforce the rules that keep it safe. You get pattern matching, traits, generics with monomorphisation, macros, zero-cost abstractions, and no runtime garbage collector. In exchange, you have to think about ownership, lifetimes, and borrows, and the compiler will absolutely refuse to let you be sloppy.

Neither of those is a moral position. They are trade-offs, and which trade-off is right depends entirely on what you are building.

The problems both languages solve well

Let me start with the overlap, because it is bigger than the internet suggests. There is a whole category of work where either language will do a good job and the decision should be made on team skills and hiring, not on benchmarks.

Command-line tools. Both produce a single binary you can drop on a server with no runtime. Both have great argument parsing. Both start in milliseconds.

Network services and APIs. Both handle thousands of concurrent connections comfortably. Both have mature HTTP stacks: net/http and Gin on one side, Axum and Actix on the other.

DevOps and infrastructure tooling. Docker, Kubernetes, Terraform, and Prometheus are written in Go. Meanwhile Rust is showing up inside those ecosystems for the parts that need to be fast or safe: linkers, proxies, container runtimes.

Microservices. Both are excellent. Neither needs a JVM or a Node process warming up. Memory footprints are modest.

WebAssembly. Both compile to WASM and are used for it. Rust is further along for browser-side compute-heavy work; Go’s WASM output is heavier because it ships a runtime.

gRPC and protobuf. Both have first-class support and generated code that actually works.

So the interesting question is not “which is better”. It is: which of the remaining differences actually matter for your problem?

Problem 1: Lots of concurrent connections with boring logic

This is Go’s home turf, and it is not close. Go’s concurrency model is the reason the language exists.

func fetchAll(urls []string) []string {
    var wg sync.WaitGroup
    results := make([]string, len(urls))

    for i, url := range urls {
        wg.Add(1)
        go func(i int, url string) {
            defer wg.Done()
            resp, err := http.Get(url)
            if err != nil {
                results[i] = "error: " + err.Error()
                return
            }
            defer resp.Body.Close()
            body, _ := io.ReadAll(resp.Body)
            results[i] = string(body)
        }(i, url)
    }

    wg.Wait()
    return results
}

That is the whole concurrency story. go spawns a goroutine, WaitGroup waits, channels or a mutex share state. Goroutines start at a couple of kilobytes and the runtime multiplexes them onto OS threads. You can have a hundred thousand of them and the scheduler will cope.

The trade-off: Go’s runtime can pause your program to collect garbage. For a request handler that is completely fine. For a trading engine or an audio callback, it is not.

Rust’s equivalent is async/await on top of Tokio:

async fn fetch_all(urls: Vec<String>) -> Vec<String> {
    let mut tasks = Vec::new();

    for url in urls {
        tasks.push(tokio::spawn(async move {
            match reqwest::get(&url).await {
                Ok(resp) => match resp.text().await {
                    Ok(body) => body,
                    Err(e) => format!("error: {e}"),
                },
                Err(e) => format!("error: {e}"),
            }
        }));
    }

    let mut results = Vec::new();
    for task in tasks {
        results.push(task.await.unwrap_or_else(|e| format!("task failed: {e}")));
    }
    results
}

It works, it is fast, and it has no garbage collector. But look at what you had to know: tokio::spawn, async move, the Send + 'static requirement on futures, the fact that holding a non-Send value across an .await will fail to compile with an error message the length of a paragraph. I have spent real afternoons on that last one.

Rust’s async is genuinely excellent engineering. Go’s concurrency is genuinely easier to teach. If your team has never written Rust and your problem is “call twelve services and merge the results”, Go will be in production while the Rust team is still arguing about lifetimes.

Problem 2: CPU-bound work where every second costs money

Now flip it. A nightly batch job with a hard deadline, a log parser, an image pipeline, a compression step, a search indexer. This is where Rust earns its reputation.

use std::fs::File;
use std::io::{BufRead, BufReader};

fn total_revenue(path: &str) -> Result<f64, Box<dyn std::error::Error>> {
    let file = File::open(path)?;
    let reader = BufReader::new(file);
    let mut total = 0.0;

    for line in reader.lines() {
        let line = line?;
        let mut parts = line.split(',');
        let _id = parts.next();
        if let Some(amount) = parts.next() {
            total += amount.trim().parse::<f64>()?;
        }
    }

    Ok(total)
}

Rust gives you zero-cost abstractions, no GC pauses, and predictable memory usage. On this kind of workload I have consistently seen Rust do the same job in a fraction of the time and a fraction of the memory, mostly because it does not allocate when it does not have to, and it does not stop the world to clean up.

The Go version of the same loop is not slow. It is maybe two to four times slower on the parser and it allocates more per line. For one gigabyte, nobody notices. For a nightly four-gigabyte job with a deadline and a bill attached, you notice.

The honest counterpoint: most services are not CPU-bound. They wait on a database, a network call, or a disk. If your program spends 90% of its time waiting, the language’s raw speed is nearly irrelevant, and Go’s simpler model wins on total cost of ownership.

Problem 3: Code where a bug is expensive

There is a category of software where “it works on my machine” is not good enough: payments, medical devices, embedded controllers, cryptography, anything that runs in a kernel. Rust’s ownership model makes entire bug classes impossible, not just unlikely.

fn main() {
    let data = String::from("hello");
    let a = &data;
    let b = &data;
    println!("{a} {b}"); // fine: many readers

    // let c = &mut data; // compile error: cannot borrow as mutable
    // println!("{a}");   //                      while also borrowed as immutable
}

That is a silly example, but the same rule stops use-after-free, double-free, and iterator invalidation in real code. Rust has no null pointers in the usual sense (Option<T> instead), no data races by construction (the compiler enforces Send/Sync), and errors are values you cannot silently ignore.

Go has none of that. It has nil, it has races that go test -race may or may not catch, and its error values are so easy to ignore that linters exist specifically to complain about it. I love Go, but if I am writing the code that moves money, I want the compiler standing between me and a 4 a.m. incident.

Problem 4: Error handling, and how each language makes you feel about it

This difference tells you almost everything about the two communities.

Go makes errors explicit and boring:

user, err := repo.Find(ctx, id)
if err != nil {
    return nil, fmt.Errorf("find user %s: %w", id, err)
}

Four lines, no magic, impossible to miss. In Go 1.13+ you can wrap with %w and check with errors.Is. The repetitive if err != nil blocks are the price of never wondering what a function can fail with.

Rust makes errors a value you have to handle:

fn find_user(repo: &Repo, id: &str) -> Result<User, RepoError> {
    let user = repo.find(id)?;
    Ok(user)
}

The question mark operator propagates the error, and the return type is honest about it. Callers cannot forget to deal with Result unless they explicitly .unwrap(), and even then you can lint against it in production code. Once you get used to ?, going back to manual propagation feels like driving without power steering.

Which is better? After years of both, I think Go’s approach is better for large teams that need to read each other’s code quickly, and Rust’s is better for code where recoverable failure paths matter and you want the compiler to prove you handled them. Also, Rust’s thiserror and anyhow crates are so good that I miss them in Go more than I expected.

Problem 5: Build time and the inner loop

This one is underrated and it changes how you work.

Go compiles a medium-sized service in a few seconds, often less than one. It has an excellent build cache, and go run feels like a scripting language. go test starts almost instantly. You write, run, iterate, and it stays out of your way.

Rust compiles slowly. Not “Java slow”, but a fresh build of a service with a web framework and a database driver can take a minute or more, and incremental builds after a small change still take several seconds. Link time is frequently the worst part. Once you add a heavy dependency tree, cargo build becomes the thing you do before going to make coffee.

People who have only used Rust will tell you it is fine and you get used to it. People who have only used Go will be shocked by it. Both are telling the truth. My own experience: on a large Rust project I started batching my changes because I did not want to lose the compile, which is a subtle way the language shapes your behaviour.

Problem 6: Teams, hiring, and the six-month question

Here is the part that never appears in benchmarks.

A Go developer with three months of experience can read and modify a Go service confidently, because there are so few ways to express the same thing. A Rust developer with three months of experience can write Rust, but they will still be fighting the borrow checker occasionally, and they will still be learning which patterns the community considers idiomatic.

If you are hiring for a large team, especially in a market where Rust experience is rare and expensive, Go’s shallow learning curve is a strategic advantage. It is not that Go developers are cheaper. It is that the whole team can be productive sooner.

If you are a small team of strong engineers building something where performance or safety is the product, Rust’s steepness is worth it. The compiler is doing a review that a human would otherwise have to do, every single day.

The problems both languages solve, side by side

Problem Go Rust
HTTP API with many connections Excellent, simplest option Excellent, more code
CLI tool distributed as a binary Excellent, builds fast Excellent, builds slowly
CPU-heavy batch processing Fine, slower, more allocations Best in class
Memory safety in critical code Good discipline required Enforced by compiler
No garbage collector needed No Yes
Fast onboarding for new hires Very good Weeks to months
Compile speed Very fast Slow
Tiny containers Small binary, static Small binary, static
Ecosystem for web backend Mature and boring Strong and growing
Ecosystem for embedded/game engines Thin Strong

Notice that nine of those rows say both are good. That is not a cop-out; it is the actual state of the world in 2026. The interesting columns are the ones where they differ, and those differences are about cost of change as much as runtime.

What I would not use either for

A fair comparison also includes the cases where you should choose neither.

For a CRUD admin panel with forms and a dashboard, the right answer is probably still Rails, Laravel, Django, or Next.js. Writing it in Go or Rust is possible and you will spend more time on boilerplate than on the product.

For data science and analytics, Python with its ecosystem will beat both, even though both have decent bindings.

For a weekend script to rename some files, Bash or Python is fine and Go is overkill.

Choosing Go or Rust should be a decision about long-lived software, not about your curiosity on a Saturday.

Some concrete code, same job, both languages

Let me do one small side-by-side, because syntax debates are better with actual code. Here is a JSON API endpoint in Go:

type User struct {
    ID    string `json:"id"`
    Email string `json:"email"`
}

func getUser(repo *Repo) http.HandlerFunc {
    return func(w http.ResponseWriter, r *http.Request) {
        user, err := repo.Find(r.Context(), r.PathValue("id"))
        if err != nil {
            http.Error(w, "not found", http.StatusNotFound)
            return
        }
        w.Header().Set("Content-Type", "application/json")
        json.NewEncoder(w).Encode(user)
    }
}

And the same idea in Rust with Axum:

async fn get_user(
    State(repo): State<Arc<Repo>>,
    Path(id): Path<String>,
) -> Result<Json<User>, StatusCode> {
    let user = repo.find(&id).await.map_err(|_| StatusCode::NOT_FOUND)?;
    Ok(Json(user))
}

Both are readable. Go’s version is more lines but each line is obvious. Rust’s version is denser and hides the error mapping in a ?, which is elegant once you know what ? does and opaque if you do not.

That is the whole comparison in miniature: Go is explicit and slightly repetitive, Rust is concise and requires background knowledge.

My decision checklist

I have used both long enough that I no longer pick by preference. I ask these questions, in this order:

  1. Is the workload CPU-bound or memory-bound? If yes, and the numbers matter, Rust.
  2. Does the service need a garbage collector to be absent? Real-time audio, trading, embedded, kernel-adjacent work: Rust.
  3. Is the team new to systems languages? Go. You will be in production much sooner.
  4. Is hiring for this role going to be hard? Go, unless you are in a market with strong Rust supply.
  5. Will this thing be maintained by five people over five years? Go’s small surface area ages better.
  6. Do we need to guarantee memory safety in critical code? Rust, and it is not a close call.
  7. Does the ecosystem have what we need? Check first. Both have gaps, in different places.
  8. Is this a service that mostly waits? Either. Pick the one your team can debug at 2 a.m.

If the answers conflict, which they often do, I default to Go for services and Rust for anything where a slow path or a memory bug is the actual product.

About “rewrite it in Rust”

I want to say something about this, because I have seen it go badly.

A team I know had a Go sync service that worked fine. Someone read a benchmark, and the service was rewritten in Rust. Six months later it was faster, yes, but it had taken three times as long to build, only one engineer understood the async error handling, and the on-call rotation had become a lottery. The bottleneck was never the language. It was a database index.

Rewriting in Rust to gain 20% throughput is usually a bad trade. Rewriting in Rust because you need predictable latency, no GC, or memory safety guarantees is often a very good trade. Know which one you are doing.

Closing thoughts

I would not want to live in a world with only one of these languages. Go got me to production faster than anything else I have used, and it is the language I recommend to teams who need to move. Rust taught me more about memory and ownership than any course, and it is the language I trust most when the code must be correct.

Pick by Problem, Not by Pride

blog-img

If you are choosing right now: start with the workload. If it mostly waits, Go will make you productive and your teammates happy. If it mostly computes, or if a memory bug is unacceptable, Rust will cost you more at the start and pay you back at the end. And if you are already running a team, the honest answer is often "use the one we can debug together at 2 a.m.", which has very little to do with benchmarks and a lot to do with shipping software people actually enjoy maintaining. Either way, learn a little of both. Understanding why Rust needs the borrow checker makes you a better Go programmer, and understanding why Go refuses to have it makes you appreciate what Rust is protecting you from. 🦀🐹

Comments

comments powered by Disqus