Writing ·
When Rust Is Worth It, and When It Isn’t
Rust is a programming language that can deliver the speed and control of C and C++ without whole classes of the bugs that come with them. Given the choice, I write Rust. Rilbo, Chantler Solutions’ own issue tracker, is written in it.
That’s exactly why I’m careful about recommending it. A language I enjoy isn’t automatically the right one for your team, and Rust has real costs, including the cost of hiring for it and maintaining it after I’ve gone.
For an existing system, Rust rarely justifies a rewrite. Where it pays is usually one small, performance-critical piece, rewritten in Rust and called from the code you already have. Here’s how I decide.
What Rust buys you
Speed. I’d put Rust’s performance in the same league as C and C++, and the Rust project describes the language as fast and memory-efficient, with no garbage collector.
Memory safety without a garbage collector. The usual runtimes for C#, Go, TypeScript and Python (the support code that runs alongside a program) use a garbage collector, which finds memory the program no longer uses and frees it while the program runs. C leaves freeing memory to the programmer. C++ can free it automatically when an object reaches the end of its life, but it’s still up to the programmer not to use memory after it has been freed.
Rust cleans up automatically too: a value is dropped (and its memory freed) normally when its owner reaches the end of the block of code it was declared in, or when the variable is given a new value. Nothing has to search memory while the program runs. What Rust adds is that the compiler (the tool that turns source code into a program you can run) checks a set of ownership rules. Every value has an owner. When a string moves to a new variable, for example, only the new variable can be used to read it, so the two can’t both free the same memory. And the compiler guarantees that a reference to some data can’t outlive the data, so safe code can’t use memory after it has been freed.
These guarantees apply to safe Rust: ordinary Rust, in which the language guarantees that its memory-safety rules hold. The compiler checks most of them before the program runs. A few are checked while it runs, and breaking one is caught rather than corrupting memory: depending on the operation, it returns an error or panics (a panic is Rust’s response to an unexpected, unrecoverable error). Rust also has unsafe code, where the programmer, not the compiler, vouches for certain operations.
Fearless concurrency. A thread is one sequence of work that can run alongside others in the same program. A data race happens when two threads use the same memory, at least one of them writes, at least one access isn’t atomic (an operation other threads always see as complete, never half-done), and nothing orders one access before the other. Safe Rust guarantees there are no data races. The compiler rejects many unsafe ways of sharing data before the program runs, and types such as a mutex (a lock that lets one thread at a time use a piece of data) enforce the rest while it runs.
That isn’t every concurrency bug. If two threads each read a counter and then write back that value plus one, locking the read and the write separately, one update can be lost. That’s a logic error, not a data race, and Rust allows it. Safe Rust doesn’t prevent deadlocks (two threads each waiting forever for a lock the other holds) or memory leaks either.
Less hardware and energy. Rust programs can start quickly and use little memory, and they usually need smaller, cheaper servers, which also means less energy, and efficiency matters to me. How it shows up on the bill depends on how you pay. On servers that run all the time, the saving comes from running fewer or smaller ones. Where you pay only while your code runs (a batch job on a machine you stop when it finishes, or a serverless function, which the cloud provider runs only when it’s called and bills for its running time), finishing sooner costs less directly, and on some plans so does using less memory. (More on that in where your cloud bill actually goes.) Either way, measure your own workload.
What it costs
Rust takes time to learn. Its own book says so: “Because ownership is a new concept for many programmers, it does take some time to get used to.” Until it clicks, you’ll write code that C# or Python would accept and the Rust compiler rejects.
The bigger cost is people. If nobody on your team writes Rust, every Rust component is either a hiring requirement or a training plan, and someone has to review and maintain it after the engagement ends. That’s why the size of the Rust part matters so much.
Where it pays off
The hot path. Most systems spend most of their time in a small part of the code, called the hot path. Rewriting that part in Rust and calling it directly from the existing C#, Go, TypeScript or Python can pay off well, once you’ve measured that the time really goes there. It’s the same principle as in Don’t Rewrite It: change the piece that matters, not the whole system.
Services that must be fast and predictable under load. Rust has no garbage collector of its own, while the .NET and Go collectors sometimes pause the program’s threads, however briefly. A Rust component inside a C# or Go service doesn’t remove the host’s collector, though, so measure how long the whole request takes, not only the Rust part.
Command-line tools and single-binary applications. A command-line tool is one you run by typing a command. A single binary is one executable file that contains the whole program, which makes it easy to distribute and run. Rilbo is an example: one Rust executable with the web interface, the API (an interface other programs can call) and an MCP server (MCP is a standard way for AI tools to use other software) built in, and all the data in a single SQLite file (SQLite is a database that lives in one file).
Software where a crash or a data race is expensive. Safe Rust rules out whole classes of those failures before the software ships, rather than leaving them to be found in production.
Rust can also be the core of a larger product. For an AI app-building platform, I designed and built a desktop agent that helps organisations move legacy software onto the platform. It works on the user’s own device, and no data leaves it until the user has seen exactly what will be sent and approved it. It’s a Rust workspace of around 18 crates (units of code that Rust compiles together), with a desktop app built with Tauri (a toolkit for desktop apps), a CLI (command-line interface) and a local MCP server, and its security guarantees are enforced by automated tests rather than only stated as policy.
Calling Rust from the code you already have
FFI, a foreign function interface, is a way for one language to call functions written in another. Rust can expose a function under an agreed name using C’s calling conventions (the agreed way the two sides pass arguments and return a result), and C# uses a feature called P/Invoke to call it. The cost is the boundary itself, which has to be designed and tested:
- The compiler can’t check across it. Other languages don’t follow Rust’s rules. A bad input that the Rust side can inspect, such as an index (a position in a list) beyond the end of the data, should be checked and rejected with an error. But if the caller breaks a rule that Rust relies on, for example by passing a buffer (a block of memory holding data) with a length longer than the buffer really is, or a pointer to memory that has already been freed, the result is undefined behaviour: the program may do anything, and the damage can show up anywhere in the process, including in safe Rust.
- Memory needs an agreement. For every pointer (the address of a piece of memory) passed either way, the interface has to say how much memory it covers, whether the receiver takes ownership or only borrows it, how long it stays valid, and, if it needs releasing at all, who releases it and how. Memory has to go back to the allocator (the code that hands out and reclaims memory) that provided it, so a common design is a release function exported by the Rust library.
- Crossing costs time. Passing data across can mean converting it (marshalling), although simple types that both sides lay out in the same way need no conversion. Each call from .NET into native code also has a small cost of its own, so design calls that each do a worthwhile amount of work, rather than one call per item in a loop. Measure the boundary as part of any benchmark.
- Panics need a decision. Expected failures should come back as error values. If a panic escapes through the exported function, the whole process ends, host and all (guaranteed since Rust 1.81, released in 2024; older versions didn’t guarantee what happened). A component built to unwind (to work back through the running functions, running their clean-up code) can catch a panic first and return an error the caller understands; in one built to abort on panic, any panic ends the process. Decide what a panic means for the host, and test it.
- There’s more to build: a native library (compiled code for one operating system and processor) for every platform, with tests on both sides.
At Microsoft, in a high-security government delivery team, I built production services in C# with performance-critical components in Rust and Go. I also built and benchmarked equivalent implementations in Python, Go, Rust and C#, called from C# through FFI, to compare their performance and trade-offs. I won’t quote numbers here: a benchmark of someone else’s workload tells you little about yours. Measure your own, boundary included.
When Rust isn’t the answer
- When the bottleneck is the design, the database or the infrastructure. At Neilson Financial Services, a performance rework cut the database calls needed to render a single page (I told that story in Don’t Rewrite It). A faster language wouldn’t have fixed a page making far too many round trips to the database.
- When your team can’t maintain it after the consultant leaves.
- When the language you already have is good enough. It often is.
So it depends: on how much speed or predictability is worth to the business, who will own the code, how long it will live, and how big the Rust part would be. I’m equally happy working in Go, TypeScript and C#/.NET, and I’ll recommend whatever your team can maintain.
Learning it
If your team does want to learn Rust, I run Rust Primer, a hands-on course for programmers who already code and want to read, write, review and steer Rust with confidence, using AI as a tutor rather than an authority. Its articles are free to read. As I write this, in November 2026, the course itself is in private alpha.
The short version
Rust earns its cost where speed, predictability or reliability are worth paying for, and where someone will be there to maintain it. For most existing systems, that means one small piece, not a rewrite.
If you’re weighing up Rust for a system you depend on, read more about Rust engineering, or get in touch.