Don't Rewrite It in Rust (Yet)
At a glance
-
Agents make writing code cheap
-
Rewrite-it-in-Rust is a trap for most web code
-
V8 isolates + JIT are already efficient
-
Business logic in Workers, heavy CPU in sidecars
-
Svelte: compiled, no VDOM, cheap build
-
Optimize the right thing, and stay objective
Don't Rewrite It in Rust (Yet)
TL;DR: AI coding agents have cut the time it takes to write software, especially high-level code, so rewrites now feel almost free. That makes it tempting to rewrite everything in the "fastest" language, and that's a trap. Compute is still finite, and Rust's compile times and multi-GB build artifacts are real costs. For web backends, V8 isolates (Cloudflare Workers) are already efficient enough: keep the business logic there and move the heavy work into a sidecar. On the frontend, Svelte is a good middle ground: compiled to plain JS, no virtual DOM, a tiny runtime, and a build that takes seconds. Optimize what actually matters, know what each change affects, and ask your agent to be objective instead of agreeable.
Coding is supercharged
The cost of writing code has dropped a lot. With an agent, a feature that took a day takes an hour, and porting a codebase from one framework to another is a weekend project instead of a quarter. High-level code (web apps, CRUD, glue) benefits the most, because it's exactly the kind of code agents have seen millions of times.
This changes the math. When rewriting is cheap, "should we rewrite this in X?" stops being a rhetorical question. That's good, but it also opens a new way to waste time.
The Rust rewrite pitfall
The obvious temptation is: if code is free to write, why not write everything in the fastest language? Rewrite the backend in Rust and squeeze out every millisecond.
Writing the code is only one cost. Compute is still finite, and Rust spends a lot of it before your program ever runs:
- Compilation is heavy. A medium Rust project with a typical web dependency tree takes minutes to build cold and needs a lot of CPU and RAM to do it.
- Build artifacts are huge. A
target/directory routinely reaches several gigabytes, and tens of GB across debug, release and multiple projects isn't unusual. That's disk on your laptop, in CI caches and on every agent's sandbox. - Agents iterate in loops. Every edit, compile, test cycle pays that compile cost again. Fast languages with slow builds make the agent loop slow.
So the question isn't "is Rust faster?" It is. The question is whether the speed you gain is worth what you pay in build time, CI and iteration speed, for this particular piece of code.
Web backends: V8 isolates are already plenty
For a typical web backend, most request time is spent waiting on a database, an API or the network, not on CPU. That's where Cloudflare Workers shines.
workerd runs your code in V8 isolates:
- Isolates start in milliseconds and use a few MB each, far less than a container or VM per tenant.
- V8's JIT compiles hot paths to optimized machine code, so for I/O-bound business logic the gap to Rust is small and usually invisible behind network latency.
- The build is plain TypeScript bundling: seconds, not minutes.
One caveat: Node compatibility (nodejs_compat) and large npm dependency trees add weight. Keep them to a minimum anyway. A Workers backend should mostly be business logic: validation, routing, orchestration, talking to D1, R2 and Durable Objects.
The heavy lifting (image or video processing, ML inference, big number crunching) belongs in a companion sidecar, and that's the place where Rust or another compiled language earns its cost. You get native speed exactly where the CPU goes, and fast iteration everywhere else.
Frontend: why Svelte is a cheap win
On the frontend I like Svelte for a similar reason: it gets real efficiency without a heavy cost.
- No virtual DOM. Components compile to direct DOM updates instead of diffing a tree every render.
- An almost invisible runtime. Svelte 5's runtime is small; React plus React DOM plus a router is roughly 100 KB gzipped before you write any app code.
- Fine-grained reactivity. With runes (
$state),item.selected = nulljust works. No nested spreads, no memoization tricks, and less code for an agent to get wrong. - The build is light. It's a transpilation step, not a compiler marathon. With Bun and Vite it finishes in seconds and leaves a small output folder, nothing like Rust's
target/.
That's the sweet spot I'm looking for: a meaningful gain in performance and ergonomics, for a small cost in build time and complexity.
Closing: optimize the right thing
AI agents make massive optimization feel cheap, so it's easy to fall into optimizing the wrong thing. A rewrite that makes a 5 ms handler 2 ms faster doesn't matter if the request spends 200 ms waiting on the database. A faster language doesn't help if it makes every build, CI run and agent loop slower.
As engineers we still have to know what a change affects: build time, artifact size, iteration speed, hosting cost, hiring, and the actual bottleneck. The agent writes the code, but deciding what to build is still our job.
And be careful with agents themselves. They can be highly sycophantic: ask "should we rewrite this in Rust?" and they'll often happily say yes and start typing. Ask them to be objective instead: measure first, list the trade-offs, point out where you're wrong. Then you decide the next steps.