# Microsoft Distinguished Eng: Why And How To Port Your Entire Codebase to Rust | Stephen Toub

DevFeed: [Microsoft Distinguished Eng: Why And How To Port Your Entire Codebase to Rust | Stephen Toub](<https://devfeed.tech/articles/microsoft-distinguished-eng-why-and-how-to-port-your-entire-codebase-to-rust-stephen-toub-113339.md>)

Original publisher: [Read original article](<https://www.developing.dev/p/e073-stephen-toub>)

Author: Ryan Peterman

Published: 2026-11-02T14:05:40Z

Content type: article

Language: en

Sources: [The Developing Dev](<https://devfeed.tech/sources/the-developing-dev.md>)

Topics: [Rust](<https://devfeed.tech/topics/rust.md>), [developer-productivity](<https://devfeed.tech/topics/developer-productivity.md>), [Integration testing](<https://devfeed.tech/topics/integration-testing.md>), [Deployment Strategies](<https://devfeed.tech/topics/deployment-strategies.md>), [Pull Request](<https://devfeed.tech/topics/pull-request.md>), [CI/CD](<https://devfeed.tech/topics/cicd.md>), [engineering-culture](<https://devfeed.tech/topics/engineering-culture.md>), [observability](<https://devfeed.tech/topics/observability.md>)

Tags: [agentic](<https://devfeed.tech/tags/agentic.md>), [ai](<https://devfeed.tech/tags/ai.md>), [article](<https://devfeed.tech/tags/article.md>), [code](<https://devfeed.tech/tags/code.md>), [microsoft](<https://devfeed.tech/tags/microsoft.md>), [port](<https://devfeed.tech/tags/port.md>), [rust](<https://devfeed.tech/tags/rust.md>), [software](<https://devfeed.tech/tags/software.md>)

## AI overview

The Copilot runtime was ported from TypeScript and Node.js to Rust so it could be embedded across more products and languages, while improving efficiency and startup speed. Rust was selected after small prototypes compared several languages and runtimes: C# with Native AOT performed similarly and also met embeddability goals, while Rust fit GitHub's existing expertise better. Because the agent runtime was changing rapidly, the team migrated incrementally in the shipping codebase, releasing daily; this enabled production validation on small changes but required temporary TypeScript-Rust interop. End-to-end tests were the main safeguard, though gaps, concurrency differences, and agents changing tests or functionality still led to regressions. Toub reports roughly 14-15 weeks elapsed, about three weeks of his time, and an estimated $120,000 in model tokens at public prices; the actual port grew to around 400,000-450,000 lines as the codebase expanded and CLI functionality was separated. His guidance is to assess a rewrite by its business value, cost, and return, and to preserve behavior through strict ports and strong tests.

## Source excerpt

In the year 2000, Joel Spolsky (founder of Stack Overflow) wrote a famous article titled "Things You Should Never Do, Part I." In it, he talks about how rewriting your code from scratch is the single worst strategic mistake any software company can make.