The Mojo Programming Language book#
A Comprehensive Guide to the Mojo programming language with real-world use cases, written to transform beginners into confident, professional Mojo developers.
Note
This book is updated frequently to track the fast-moving Mojo language. The code and syntax here follow the current Mojo release (the 1.0 beta series). If you spot something that has drifted from the latest official docs, please open an issue on GitHub.
To support this work, please give this repository a ⭐ star, follow me on X, and subscribe to my YouTube channel for the latest updates.
How this book is organized#
We start with why Mojo exists and what problem it solves, get your machine set up, and then build up the language one idea at a time — data types, control flow, functions, your own data structures, packages, and Python interop. From there we move into the ideas that make Mojo special: traits, an object model built for performance, metaprogramming, and the MLIR foundation underneath it all. We finish with the practical muscle: collections, parallelism, and a tour of the standard library.
Each chapter assumes only what came before it. If you read straight through, every new idea will rest on something you have already seen.
- Why Mojo
- Getting started
- Data Types, Variables and Operators
- Loops & Control Flow
- Functions
- Data Structures: Building Your Own Types
- Modules and Packages
- Using Python
- Traits
- OOP Concepts in Mojo
- Metaprogramming in Mojo
- MLIR: The Engine Under the Hood
- Thinking in Mojo
- Arrays, Lists and Comprehension
- Parallelization
- Value ownership
- Value lifecycle
- Pointers
- The Standard Library
Where this series is heading#
This book teaches you the language itself. Once you are comfortable here, the next parts of this series put Mojo to work on the kind of problems I deal with every day as an AI research engineer:
Data Analysis & Data Mining
Data Visualization
Data Transformation and preparing your data
Machine Learning models — training, testing, and evaluation
Deployment and hardware testing
Mojo was built for exactly this path — from a quick idea in a notebook all the way to production hardware — and that is the journey we are on together. 🔥