Why Rust Is The New GOAT For AI

6:243 min readBetter Stack10/24/2026Computing/Software · Internet Technology

Key Takeaway

Major tech companies are rewriting their AI tooling and runtimes in Rust because its ownership model eliminates memory safety bugs and garbage collection latency while drastically improving performance.

Highlights

  • GitHub rewrote the runtime behind Copilot in Rust, which reduced session start and reply times from over five seconds to under 300 milliseconds.

  • Google measured its Android Rust code and found it has about a thousand times fewer memory bugs per line than its C and C++ code.

  • GitHub ported about 430000 lines of TypeScript into 832000 lines of Rust and 470000 lines of tests in about 14 and a half weeks using Copilot agents.

  • Popular Python libraries like Hugging Face's tokenizers, OpenAI's ticktoken, Pydantic version 2, and the uv package manager all run on Rust underneath.

  • In a 2025 Stack Overflow survey, 72% of developers using Rust stated they want to keep using it.

Timeline

  1. The Industry Shift Toward Rust

    The artificial intelligence industry is experiencing a massive migration toward Rust for core tooling and runtimes. Prominent platforms and models from GitHub, Anthropic, OpenAI, and xAI are abandoning languages like TypeScript and Zig in favor of Rust to gain massive speed improvements and eliminate performance bottlenecks.

    • Elon Musk stated that xAI's code is mostly Rust.
    • GitHub rewrote Copilot's runtime in Rust to slash response times.
    • Claude Code moved from Zig to Rust, and OpenAI's Codex CLI is now 97% Rust.
  2. The Origin and Memory Safety Crisis

    Memory management has historically plagued software reliability through manual errors in languages like C and C++ or random pauses from garbage collectors in languages like Go and Java. Discord experienced severe latency spikes every two minutes due to Go's garbage collector until rewriting the affected service in Rust eliminated them completely.

    • A Mozilla programmer created Rust in his spare time after recurrent elevator software crashes caused by C and C++ memory errors.
    • Microsoft and Chrome previously found that about 70% of their high-severity or CVE-assigned security bugs were memory safety bugs.
    • Garbage-collected languages introduce unpredictable latency and CPU spikes due to background cleaning cycles.
  3. Rust Mechanics and Copilot Performance

    By enforcing strict compiler rules where memory has a single owner and requires no background garbage collection, Rust achieves high speed without safety trade-offs. This architectural difference allowed GitHub Copilot to drop its initialization and response time from 5.25 seconds down to 292 milliseconds by removing the heavy Node runtime dependency.

    • Rust assigns each piece of memory exactly one owner, freeing it immediately when that owner is finished.
    • The old TypeScript-based Copilot runtime required every app using the SDK to start a separate Node process consuming 100 megabytes of memory.
    • Compiling to a single native file allows applications to load Rust straight from their own process like a plugin.
  4. Developer Experience and AI Agent Integration

    Developers continually rate Rust as an admired language due to its comprehensive tooling via Cargo and precise error messaging. These detailed compiler errors benefit AI coding agents as well, enabling automated ports such as GitHub rewriting hundreds of thousands of lines of code using autonomous agents in just over 14 weeks.

    • The Rust compiler points to exact lines and suggests fixes when code breaks memory rules.
    • Google rolls back its Android Rust changes four times less often than C++ changes and spends 25% less time in code review.
    • AI agents successfully write Rust because detailed compiler feedback allows them to quickly fix errors and iterate.
  5. Python's Rust Foundation and GPU Code

    Developers writing Python for AI do not need to abandon the language because underlying performance-critical libraries are already powered by Rust. With Nvidia introducing experimental support for writing GPU kernels in Rust, the language's footprint in high-performance computing and machine learning continues to expand.

    • Python remains the primary interface for writing AI and data code while heavy number-crunching runs on Rust underneath.
    • Hugging Face tokenizers, OpenAI ticktoken, Pydantic v2, and uv all utilize Rust cores.
    • Nvidia recently announced its own method to write GPU kernels in Rust.

Description

The Copilot runtime was rewritten in Rust and starting a session fell from over five seconds to under 300 milliseconds. The Codex CLI and Bun made the same move, and tokenizers, tiktoken, Pydantic and uv already run on Rust underneath. If you build AI tools or write Python for a living, here's why this keeps happening. 🔗 Relevant Links https://rust-lang.org ❤️ More about us Radically better observability stack: https://betterstack.com/ Written tutorials: https://betterstack.com/community/ Example projects: https://github.com/BetterStackHQ 📱 Socials Twitter: https://twitter.com/betterstackhq Instagram: https://www.instagram.com/betterstackhq/ TikTok: https://www.tiktok.com/@betterstack LinkedIn: https://www.linkedin.com/company/betterstack 📌 Chapters: 0:00 "Rust" vs Python for AI 0:45 Why Rust was invented 1:24 Why memory causes crashes 2:10 The garbage collector problem 2:33 How Rust handles memory 2:57 How Copilot dropped to 292ms 3:49 Why developers love Rust 4:24 Rust and AI agents 4:58 Python runs on Rust 5:34 Rust on the GPU

Write about this video