Why Rust Became the Top Choice for AI Programming: A GitHub Engineer's In-Depth Retrospective

GitHub engineer's Rust rewrite retrospective: success hinges on testing and review guardrails, not the compiler.
Distinguished GitHub engineer Steven Tube details migrating the Copilot runtime from TypeScript to Rust with AI agents, debunking the claim that Rust's strict compiler suits AI programming. Only 1.7% of errors were Rust-specific; 84% were ordinary type errors. The real driver was leaving Node.js/V8, making the runtime a native library for six SDKs, and reducing dependencies. About 430K lines of TypeScript became 800K+ lines of Rust across 128 PRs over ~14.5 weeks. Success came from immutable end-to-end tests, independent second-agent review, faithful porting before improvement, and incremental releases.
A Misunderstood AI Programming Practice
"I was wrong." This is the common reaction among many tech bloggers after reviewing the GitHub Copilot runtime rewrite project. A widely circulated view was that Rust's strict compiler error checking allows AI agents to iterate autonomously until the code compiles and all tests pass, making Rust the best language for AI programming. This claim sounds convincing—the agent can repeatedly converse with the compiler and fix type errors, borrow checker issues, and more without human intervention.
But a detailed retrospective published by a distinguished GitHub engineer (Steven Tube) shatters this simplified narrative. He used an AI agent to migrate the Copilot runtime from TypeScript to Rust, recording every prompt, every compiler error, every tool call, and every expense. The data shows: among all compiler errors, Rust-specific borrow, ownership, and lifetime issues accounted for only 1.7%, while a whopping 84% were ordinary type errors—which Java, Go, or C# compilers would also catch. The compiler's value is undeniable, but it is not the core reason Rust stood out in this scenario.

Rewrite Scale and Incremental Strategy
The rewrite replaced approximately 430,000 lines of TypeScript with over 800,000 lines of production-grade Rust, plus hundreds of thousands of lines of Rust tests. The entire process spanned 128 pull requests, merged into the main branch in stages and released incrementally, rather than waiting for a one-time switchover. The benefits of this incremental strategy are obvious: each small piece of code is tested as it enters the codebase, breaking changes can be resolved early, and minor oversights are quickly discovered by real users—instead of suddenly dropping 800,000 lines of Rust on everyone and catching them off guard.
The project took about 14.5 weeks, primarily completed by one developer with AI agents, while other team members continued to expand runtime capabilities. Before agents existed, this would typically require a full team and one to two years. The author emphasizes that this model allows the team to advance a modernization migration while maintaining the existing codebase, without pausing other development work.
Why Rust: The Compiler's Real Role
Tube explicitly states that choosing Rust had nothing to do with the compiler. His starting point was "leaving Node.js and V8," not "rushing toward Rust." Under the old architecture, every client using the Copilot runtime—whether a TypeScript application or a C#, Python, or Go program based on the SDK—would launch a separate Copilot CLI process running Node and V8, communicating via pipes. This meant each client incurred at least about 100 megabytes of additional memory overhead, and every message had to cross process boundaries.
The goal was clear: make the runtime a native library that all six SDK languages can load directly into their own process, with external process servicing becoming optional. At the same time, Tube wanted minimal dependencies and the lowest possible supply chain risk—Rust fit these conditions perfectly.

How the Agent Works: Far More Exploration Than Writing
The agent's loop is straightforward: modify a small piece of code, run cargo check, fix the issues the compiler flags, repeat until no new errors. Out of about 4,500 checks, 87% passed on the first try. Tube attributes this to the habit of "small edits, continuous recompilation."
A noteworthy detail: the agent's exploration-to-modification ratio is about 10 to 1. They spend far more time reading, understanding, and exploring the codebase than actually writing code. This contradicts the popular imagination of AI "frantically outputting code," but is much closer to how excellent human developers work—fully understanding the problem before writing code.
The Borrow Checker is the core component of the Rust compiler that enforces ownership and lifetime rules at compile time. It statically tracks the ownership of each piece of data, the mutability and lifespan of borrows, and can reject memory safety issues such as use-after-free, double free, and data races before the code runs. The borrow checker requires no garbage collection and introduces no runtime overhead, at the cost of requiring developers to explicitly clarify data ownership relationships. For code migrated from garbage-collected languages, borrow errors reported by the compiler often mean the data flow needs restructuring; for code that already managed memory manually, these errors correspond precisely to real hidden dangers. Thus the same tool has vastly different value depending on the starting language.
cargo check is a subcommand of Cargo, Rust's official build tool. It performs full type checking and borrow checking but skips code generation and linking, making it much faster than a full compilation and producing no executable. For AI agent loops that need to validate changes frequently, cargo check provides nearly all the diagnostic information of the compiler while minimizing the latency of each feedback cycle. This makes the "small edits, immediate check" strategy cost-effective—if each of the approximately 4,500 checks had triggered a full build, the token and time overhead would have risen significantly.
Beyond the Compiler: The Mechanisms That Actually Made the Rewrite Succeed
End-to-End Testing Is the Last Line of Defense
Code that compiles can still go wrong. Most surprisingly, the largest category of escaped bugs involved lifetime, ownership, ordering, and race conditions—precisely the domain the borrow checker was supposed to catch. The reason they escaped: residual TypeScript code held handles pointing to Rust state, and a handle is essentially an index into a table that can outlive the object it points to. The compiler cannot see this cross-language lifetime issue, but end-to-end tests can.
The full test suite was run on every change. Tube's reflection: more tests should have been written earlier. At one point, an agent deleted a test protecting a feature while deleting the feature itself, so the team established a rule: agents must not touch these tests.

End-to-End Testing starts from the real user entry point, drives the complete system chain, and asserts the final behavior, rather than verifying a single function or module in isolation. Its key difference from unit testing is that it covers cross-language, cross-process, and cross-abstraction-layer interaction boundaries. In this article, the lifetime issues caused by residual TypeScript indirectly accessing Rust state through handles are a typical scenario that falls outside the compiler's view but can be caught by end-to-end tests: the compiler only checks static rules within a single language, while end-to-end tests observe the real causal chain at runtime.
Dual-Agent Review and the "Faithful Port" Principle
GitHub's approach was to have a second agent review every change—an agent without the first agent's reasoning context, examining the code in isolation. Furthermore, they used review agents on three different models to compare the old TypeScript and new Rust line by line.
Another important principle: first do a faithful port, then improve. Tube found that every time the agent was allowed to "clean up" code along the way, it brought more regressions, more time, more tokens, and higher costs. Lock in behavioral equivalence first, then optimize on a stable foundation.
Performance Gains and Supply Chain Risk
The rewritten version delivers benefits including: the time to start a client, warm up a session, and get one response dropped from seconds to milliseconds; memory usage for ten clients fell from about 1.3GB to about 126MB; and about 60 NPM dependencies were removed, significantly reducing supply chain risk. Tube also cautions that other changes landed during the same period, so these benchmarks should be viewed with care, but "not having to start a JavaScript engine every time" is a real gain.

Comparison with the Bun Rewrite: Different Starting Points, Different Answers
The case of Bun migrating from Zig to Rust is often compared. Jared's opening was a bug list: use-after-free, double free, memory leaks—these cannot compile in safe Rust. After the migration, many such bugs were eliminated. But GitHub's rewrite had only 158 unsafe blocks, all at the boundary where Rust interacts with C or the operating system; none were in agent-written code, and no known bugs fell within them.
Tube is very cautious about this: his data comes from porting a garbage-collected language, TypeScript, so the agent naturally rarely triggered the borrow checker; whereas Bun came from Zig, which manages memory manually, and memory issues were the primary reason for migration. The two cannot be simply compared. He explicitly states: "This absolutely does not mean every large TypeScript program should switch to Rust."
unsafe blocks are code regions in Rust used to temporarily bypass the borrow checker and memory safety guarantees, allowing operations such as raw pointer dereferencing, calling external C functions, and accessing mutable static variables. unsafe does not disable type checking, nor does it mean the code is necessarily wrong; rather, it explicitly marks "this part of safety is manually guaranteed by the developer" for auditing and isolation. In this article, all 158 unsafe blocks are at the boundary with C or the operating system, a typical necessary scenario: memory layout and lifetimes across language boundaries cannot be statically verified by the Rust compiler and must be backed by manual review and testing.
Conclusion: The Decisive Factor in AI Programming Is Not the Language Itself
The compiler's autonomous feedback loop is indeed useful—the agent can handle trivial type errors on its own without human prompting for each one. But any statically typed language can provide most of this feedback. What truly made the rewrite succeed was: end-to-end tests the agent could not modify, independent review by a second agent, the discipline of porting first and improving later, and an incremental release strategy. These practices are language-agnostic, yet they determine the success or failure of AI-assisted large-scale refactoring.
Rust was the right choice for this project because of the native library requirement, low dependencies, and supply chain security—not the compiler. For teams considering a similar migration, the greatest value of this retrospective may not be "use Rust," but "build the guardrails of testing and review first, then let the agent write freely."
One-line Summary
GitHub engineer's retrospective on the Copilot runtime Rust rewrite: success hinges not on the compiler, but on testing and review guardrails.
Paragraph Summary
Distinguished GitHub engineer Steven Tube details the migration of the Copilot runtime from TypeScript to Rust using AI agents, debunking the popular claim that "Rust's strict compiler makes it ideal for AI programming." Data shows that among all compiler errors, Rust-specific borrow, ownership, and lifetime issues accounted for only 1.7%, while 84% were ordinary type errors that Java, Go, or C# could also catch. The real motivation for choosing Rust was to escape Node.js/V8, make the runtime a native library loadable directly by six SDKs, and reduce dependencies and supply chain risk. About 430,000 lines of TypeScript were replaced with over 800,000 lines of Rust, spanning 128 PRs and taking about 14.5 weeks. What truly made the rewrite succeed was end-to-end tests the agent could not modify, independent-context second-agent review, the discipline of faithful porting before improvement, and an incremental release strategy.
Related articles

Prompt Engineering for Beginners: From Writing Prompts to Engineering Thinking
Starting from the essence and four functions of prompts, this article systematically explains the six-step process, four success criteria, learning value, and practical limitations of prompt engineering to help you build a complete understanding.

Anthropic Launches Nasdaq IPO: AI Giant's Listing and Risk Disclosures
Anthropic officially launches its Nasdaq IPO under ticker ANT, with market valuation expected to potentially exceed SpaceX's record. The prospectus devotes nearly 100 pages to AI risks, while first-half revenue grew over 14x but net losses widened sharply, reigniting the AI bubble debate.

Rust cURL Clone Uses 4,832 unsafe Blocks—Is the Memory Safety Myth Broken?
A Rust cURL clone uses 4,832 unsafe keywords, challenging Rust's memory safety narrative. We analyze what unsafe really means, compare Fil-C, and examine rewrite motives.