Mojo 1.0: Python That Compiles to Native
Python syntax, native machine code, one language. Mojo just hit 1.0 — here's why the two-language problem in ML might be over.
Mojo 1.0 just shipped. Not another JIT, not a transpiler, not a typed-Python linter. It's a new programming language that accepts Python syntax and compiles to native machine code.
If you build ML or data tools, you know the two-language problem: prototype in Python, then rewrite hot paths in C++ or CUDA. Mojo collapses that into one language.
Why this matters
Python owns AI, but Python itself is slow. Every major framework — PyTorch, TensorFlow, JAX — handles this identically: a thin Python layer calling C++ and CUDA kernels underneath. Writing those kernels means switching languages, build systems, and mental models. Mojo lets you stay put.
How it works
Mojo compiles through MLIR, a compiler infrastructure built by Chris Lattner — the same engineer behind LLVM and Swift. MLIR lets Mojo target CPUs, GPUs, and custom accelerators from the same source code.
The language offers two function modes that coexist in the same file:
deffunctions behave like Python. Dynamic, flexible, no annotations required.fnfunctions are statically typed and compiled to native code. This is where performance lives.
Start with def for a prototype. Add types, switch to fn for hot loops. Same module, same imports, no rewrite. That gradual path from Python-like to C-like speed is the core design decision.
Where this helps
- Writing custom ML kernels without dropping to CUDA C++
- Data pipelines that currently stitch together Python, NumPy, and Numba
- Edge deployment where you need static binaries, not a Python runtime
- Systems tasks where you'd normally reach for Rust or C++
Watch out
Mojo is not a drop-in Python replacement. The CPython interop layer is improving but incomplete — many pip packages won't work natively. The standard library is still maturing. And the ecosystem is small: fewer libraries, fewer Stack Overflow answers, fewer battle-tested patterns. If your project pulls in dozens of Python dependencies, Mojo won't absorb them all today.
Try it yourself
# Save as fast.mojo
# The 'fn' keyword gives you static types + native compilation
fn fib(n: Int) -> Int:
if n <= 1:
return n
return fib(n - 1) + fib(n - 2)
fn main():
var result: Int = fib(35)
print("fib(35) =", result)
# Run it:
# mojo fast.mojo
#
# Compare with the equivalent Python — you'll see 10-100x difference.TL;DR
- What happened: Modular released Mojo 1.0 — a Python-superset language that compiles to native machine code via MLIR
- Why it matters: Prototype in
def, optimize infn, same file — no more rewriting Python in C++ for speed - What to try today: Write a recursive
fnfunction in Mojo and benchmark it against the Python equivalent