Things Have History
Mojo, or why AI researchers kept rewriting everything in C++

programming-languages

Mojo, or why AI researchers kept rewriting everything in C++

Listen · 3:58

In 2022, Chris Lattner left Google and started a company to fix one of software’s more embarrassing open secrets: the language everyone used to build AI could not actually run AI fast enough to ship. Python had won the research world on readability. It was losing it on performance.

Lattner had good credentials for the opinion. In 2000, as a graduate student at the University of Illinois, he had written a compiler infrastructure called LLVM because the existing tools frustrated him — C programs were hard to optimize, and the analysis passes were tied to specific platforms. LLVM went on to underpin Rust, Clang, and most of the compiler infrastructure that Silicon Valley runs on. He built Swift at Apple in 2014. After four years on AI hardware at Google, he co-founded Modular AI with Tim Davis, a former Google engineer, with a single target: the decade-old gap between Python prototypes and the C++ that had to be written to actually run them.

The language they built, Mojo, was unveiled publicly on May 2, 2023. It runs on MLIR — Multi-Level Intermediate Representation, Lattner’s newer compilation framework designed for modern AI hardware, where LLVM had been optimized for CPUs. Mojo uses Python’s syntax for the readable parts and adds compiled constructs — fn instead of def, struct instead of class — for the parts that need to run fast. From the same source file, the compiler can target CPUs, GPUs, TPUs, and custom AI silicon. Jeremy Howard of fast.ai called it “syntax sugar for MLIR.” That is not a diminishment.

Howard’s first encounter with Mojo in May 2023 produced an unusual review: he compared the experience to encountering Visual Basic 1.0, writing that “it felt like coding would never be the same again.” The matmul and Mandelbrot demonstrations shown at launch had been coded in a few days before the recording, and were, in his telling, “the only things we tried for the demo and they worked first time.” For a language attacking a problem that frameworks and language extensions had been failing to solve for a decade, that first-try simplicity was the real claim.

What Mojo was designed to end was the two-language problem. Write the AI prototype in Python; rewrite the performance-critical sections in C++ or CUDA for production; maintain two diverging codebases indefinitely, or until someone gave up. The cost was not only programmer time — it was research ideas that never survived the rewrite. Mojo’s compiler targets the same GPU and TPU hardware as PyTorch’s C++ backend, but from source that reads like Python. The standard library was open-sourced under Apache 2.0 in March 2024.

Mojo 1.0 shipped in August 2026, three years after the first public demo, with the compiler released as open source. The original goal of full Python source compatibility was quietly revised by early 2026 — the architecture worked better as a language with Python-inspired syntax than as Python itself — but adoption continued. Lattner had once solved a performance bottleneck by rewriting the compiler. He was doing it again. Whether it sticks is the kind of question that only runs in production.

Sources

Spot a mistake?

Wrong date, broken citation, a fact that doesn't hold? Tell us. It lands in an inbox a human reads and the post can be pulled or corrected.