Essay record

Just Write Rust

Record
Essay / / 5 min read / 1,284 words
On this page5 sections / +

DISCLOSURE: Some links may be affiliate links. Details

In The Missing Programming Language, I detailed my search for the perfect programming language - one that excelled in guardrails, performance, ecosystem, and applicability.

I never found a perfect language (surprise!) but after experimenting with various languages Rust has become my default for most projects. Here I'll make my case for why you should just write Rust - why it's a great default especially in the age of AI.

Rust has great bones

My programming language comparison across expressive types, ecosystem, community, performance, and developer experience

Rust was a frontrunner in my search for the perfect programming language because it has:

  • Types - Expressive enough to model the domain and enforce invariants. Goes further than most other general languages via ownership + borrowing. Types are a useful way to build pits of success at scale so expressive types are a non-negotiable for my projects. Plus because you aren't typically manually managing memory, you can avoid whole categories of security bugs - v important in this age of AI vulnerabilities.
  • Performance - Rust is known for strong performance. It can compete with the fastest languages all while remaining reasonably high level. You can also use it exactly like a high-level lang and still get 80% of the perf benefits which blows away most other langs for that tradeoff.
  • Ecosystem - Libraries, tooling, and community are great with corporate support and independent steering. Rust's approach at being a high-level language with low level properties make it a great fit for many kinds of applications from backend apps, low-level systems, native tools, and web targets via WebAssembly.
  • Devx - Known to have a large learning curve but once you onboard, most practitioners believe it saves them time.

So while Rust may not beat out a given language along one axis, as a package it's a clear frontrunner.

Rust has tradeoffs

Rust is great but it does have shortcomings.

  • Types - Functional langs can offer similar expressiveness for less boilerplate and in some cases may go further in what they allow you to model
  • Performance - While Rust attempts to be zero abstraction, there are still some choices that push towards being safe > fast. If you really want the most out of perf sometimes manual memory and unsafe operations will get you further, if you know what you're doing.
  • Ecosystem - Depending on the domain, other ecosystems may get you further like Python for AI or JS/TS for web. But as a general tool it's unparalleled in its ability to be run basically anywhere with such great performance and interop with other languages / ecosystems.
  • Devx - Rust has a notoriously large learning curve when coming from other programming models. In some ways you have to consider both functional (separating data from behavior) and memory which is a step beyond what most high level langs ask you to do. When used poorly, Rust can make programming feel like a huge pain and run even slower than the high level langs you might be trying to replace.

The virtuous cycle of AI + Rust

Agents are good at writing Rust and Rust provides System Guardrails for AI to write better code. Together it means we can write Rust code faster and build better systems with AI - a virtuous cycle.

  • Types - Rust's expressive types (including ownership and borrowing) builds a pit of success for both humans and agents. If you model the domain well up front you can avoid many classes of errors later. This means you can focus on the contracts and basically let the agents handle the implementation in many more cases, bringing the idea of Durable Context, Disposable Code that much closer to fruition.
  • Performance - Agents are pretty great at hillclimbing performance but Rust allows you to get great perf out of the box so in many cases you won't even need those. And when you do you can get about as close to bare metal perf as you could with any other choice.
  • Ecosystem - Rust's large ecosystem lets agents get high quality libraries and tools by default. And for those specific cases where Rust may not have the best libraries available, you can now point your agents at the best versions in other ecosystems and pretty easiy recreate what you need. Rust doesn't have many runtime constraints (like a GC) holding it back so is a pretty great target for almost anything you want to run anywhere (wasm being a good example where GCs often make interop and feasibility a bottleneck).
  • Devx - Rust's main obstacle is its learning curve but if AI is writing the Rust, does it matter? There's still something to be said for slow compilation speeds which may hinder agents from developing quickly but I'll take the "if it compiles, it works" idea over speed, esp if agents are running autonomously.

As agents continue to improve, I expect the benefits of using Rust to improve as well. Great default System Guardrails, best in class performance, and suitability for basically any class of software.

Rust Port Examples

Here I'll go over just a few examples of porting to Rust - where teams started without Rust and decided to move towards it, often for speed, memory, and/or correctness reasons (which themselves often offered greater confidence in larger architecture changes).

  • Cloudflare's Pingora - In 2022, Cloudflare replaced its NGINX-based proxy with a Rust service to improve connection reuse, support new features, and gain memory safety. It reported about 70% less CPU and 67% less memory for the same traffic load. Those gains came from architectural changes as well as the language change.
  • Figma's multiplayer server - Figma moved the performance-sensitive parts of its TypeScript multiplayer server into Rust. It reported over 10x faster document serialization and low enough memory usage to run a separate process per document. This let it isolate large documents so they no longer blocked syncing for everyone sharing a worker. The change combined a Rust port with a new process architecture.
  • Discord's Read States service - Discord ported the service tracking which messages users have read from Go to Rust. Its initial load tests matched Go's latency without the periodic garbage-collection spikes. After rollout, it also increased cache capacity to 8 million read states, alongside more memory and data-structure optimization.
  • TypeScript to Rust with tsrs - Started at Owner.com and is being developed with Cloudflare and VoidZero as part of Oxc. Cloudflare reports early benchmarks up to 8x faster and ~70% less memory than TypeScript 7.0's Go implementation with the same number of typecheck workers. The tsrs author's account describes an agent-written port backed by extensive comparison tests. The release is still experimental but I'm hopeful it'll stick with Cloudflare's backing.

Next

So that's why I think you should just write Rust.

Obviously you should do your own analysis and pick the best tool for the job but Rust joins Postgres on my toolbelt of default technologies. It may not be the best in every case but it's a great choice for 90% of cases when I need that shape of tool.

CloudSeed Rust architecture showing the Dockerized server, PostgreSQL, CSS pipeline, and OpenTelemetry observability.

If you want to see how I'm building with Rust, take a look at High-Level Rust or checkout CloudSeed for how I'm building fullstack apps with Rust.

If you liked this post you might also like:

Built with CloudSeed Rust