Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

Repository files navigation

Modern Mojo Tutorial 🔥: From Language Basics to Production Backend

A complete, beginner-friendly curriculum taking you from modern Mojo (v1.2+) fundamentals to building a production-grade backend combining FastAPI, SQLx-style SQLite persistence, and Better Auth-compatible authentication.

Managed with Astral's uv package manager for instant, reproducible setup.


⚡ What Changed Since the Alpha Era?

If you learned Mojo during its early Alpha releases, modern Mojo has matured into a stable systems language with key syntax unifications:

Feature Alpha Era (Old) Modern Mojo (v1.2+) Why It Changed
Package Management modular CLI / conda uv / PyPI (uv add mojo) Standardized under Python's fastest package ecosystem
Functions fn (strict) vs def (loose) Unified def Eliminated dual-keyword fragmentation; def has full systems safety
Variables var (mut) vs let (immut) Unified var Simplified runtime variables; compile-time constants use comptime
Compile-Time alias comptime Clearer meta-programming semantics (comptime X = 10, if comptime(...))
Standard Library from collections import List from std.collections import List Standardized under the std root namespace
Backend Architecture Raw sockets inside Mojo Compiled .so in FastAPI FastAPI handles async ASGI HTTP; Mojo handles SIMD/heavy compute

🚀 Quickstart & Setup

Prerequisites

  • macOS (Apple Silicon) or Linux: Supported natively out of the box.
  • Python: Python 3.15 (managed automatically via uv or system Python 3.15).
  • Windows: Install and run via WSL2 (wsl --install -d Ubuntu).
  • uv: If not installed, get it via curl -LsSf https://astral.sh/uv/install.sh | sh or brew install uv.

Installation

Clone the repository and install all dependencies in one command:

git clone https://github.com/vinitchuri/Mojo-Tutorial.git
cd Mojo-Tutorial
uv sync

Verify your Mojo compiler installation:

uv run mojo --version
# Output: Mojo 1.2.0 (2016d0cd)

📚 Curriculum Map

Phase 1: Core Mojo Fundamentals

Phase 2: Systems Mojo & Performance

Phase 3: Integration & Extensions

Phase 4–6: Production Backend (backend/)


🛠️ Verification & Test Suite

1. Run All Chapter Scripts

You can execute every tutorial chapter in sequence:

uv run mojo chapters/01_hello/hello.mojo
uv run mojo chapters/02_variables_and_comptime/variables.mojo
uv run mojo chapters/03_datatypes/datatypes.mojo
uv run mojo chapters/04_control_flow/control_flow.mojo
uv run mojo chapters/05_functions_and_errors/functions.mojo
uv run mojo chapters/06_ownership_and_borrowing/ownership.mojo
uv run mojo chapters/07_collections_and_structs/structs.mojo
uv run mojo chapters/08_traits_generics_and_simd/simd_compute.mojo
uv run mojo chapters/09_mojo_python_extensions/interop_demo.mojo

2. Test Chapter 09 Native Extension Compilation

uv run python chapters/09_mojo_python_extensions/run_extension.py

3. Run Pre-Flight SQLx Verifier & Backend Pytest Suite

uv run python -m backend.app.db.migrator
uv run python -m backend.app.db.verifier
uv run pytest backend/tests/ -v

4. Code Formatting & Static Type Checking

# Format and lint with Ruff
uv run ruff format .
uv run ruff check .

# Fast static type checking with Pyrefly
uv run pyrefly check

🤝 Contributing & License

Contributions, feedback, and questions are welcome! Feel free to open an issue or submit a pull request. Licensed under the Apache 2.0 License.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages