How the ai-engineering-from-scratch Curriculum Handles Language Diversity Across Python, TypeScript, Rust, and Julia

The ai-engineering-from-scratch curriculum teaches every AI algorithm through parallel implementations in Python, TypeScript, Rust, and Julia, ensuring learners understand the underlying mathematics before using high-level frameworks.

The rohitg00/ai-engineering-from-scratch repository structures its educational content around language diversity, requiring each lesson to demonstrate core AI concepts in multiple programming languages. By forcing implementations across four distinct ecosystems, the curriculum prevents framework dependency and highlights how mathematical principles translate into different language paradigms.

Explicit Language Selection and Lesson Structure

Every lesson declares its supported languages upfront in the front-matter of its documentation file. For example, phases/01-math-foundations/01-linear-algebra-intuition/docs/en.md explicitly lists "Python, Julia" as its target languages, immediately signaling which runtimes learners must install.

The repository enforces a unified directory structure across all lessons. Each lesson folder contains docs/, code/, tests/, and optional outputs/ subdirectories. Within code/, the curriculum provides main.<ext> files for every supported language. The Linear Algebra Intuition lesson includes both main.py and main.jl located at phases/01-math-foundations/01-linear-algebra-intuition/code/.

Standard Library-First Implementation Strategy

The curriculum maintains strict dependency constraints that vary by language but share a common philosophy: implement algorithms from first principles using only standard libraries or vetted minimal dependencies.

According to the AGENTS.md policy file, the permitted dependencies are:

  • Python: numpy, torch, and core standard library
  • TypeScript: hono, zod, and Node.js 20+ standard library
  • Rust: Pure standard library only
  • Julia: Limited to Random, Statistics, LinearAlgebra, and Printf

This std-lib-first policy ensures that learners implement matrix operations, gradient descent, and agent loops manually rather than importing black-box solutions.

Cross-Language Code Parity

Rather than abstracting implementations behind interfaces, the curriculum duplicates algorithms explicitly across languages. This approach lets learners compare how the same mathematical concepts express in Python's imperative style versus Julia's mathematical syntax versus Rust's type-safe systems programming.

Linear Algebra Foundations: Python versus Julia

The Linear Algebra Intuition lesson demonstrates dot product calculations using NumPy in Python and native operators in Julia.


# Python: phases/01-math-foundations/01-linear-algebra-intuition/code/main.py

import numpy as np

a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
print("a · b =", np.dot(a, b))

# Julia: phases/01-math-foundations/01-linear-algebra-intuition/code/main.jl

a = [1, 2, 3]
b = [4, 5, 6]
println("a ⋅ b = ", dot(a, b))  # Unicode operator for dot product

Both implementations compute identical scalar values, but the Julia version uses Unicode mathematical operators while Python relies on NumPy's explicit function calls.

Agent Engineering Patterns: Four-Language Comparison

The Agent Loop lesson in Phase 14 provides the minimal state-transition logic across all four languages, highlighting ergonomic differences.


# Python: phases/14-agent-engineering/01-the-agent-loop/code/main.py

def agent_step(state):
    return {"next": state + 1}
// TypeScript: phases/14-agent-engineering/01-the-agent-loop/code/main.ts
export function agentStep(state: number): { next: number } {
  return { next: state + 1 };
}
// Rust: phases/14-agent-engineering/01-the-agent-loop/code/main.rs
pub fn agent_step(state: i32) -> i32 { state + 1 }

# Julia: phases/14-agent-engineering/01-the-agent-loop/code/main.jl

agent_step(state) = state + 1

These snippets reveal how Rust enforces explicit return types, Julia supports mathematical function notation, TypeScript requires interface definitions, and Python uses dictionary structures for state management.

Development Environment and Tooling

Multi-Runtime Bootstrap

The Setup & Tooling phase ensures learners can execute code in all four ecosystems. The bootstrap script at phases/00-setup-and-tooling/01-dev-environment/code/main.rs checks for Python 3.11+, Node.js 20+, Rust, and Julia installations, reporting version information to verify environment readiness.

Unified Testing and Validation

Each language maintains its native testing framework:

  • Python: unittest module
  • TypeScript: npx tsx execution
  • Rust: Inline #[cfg(test)] modules
  • Julia: @testset macros

The CI pipeline runs the appropriate test command per lesson, while the audit_lessons.py script validates that documented language lists match actual source files present in the code/ directory.

Documentation Automation

The site generator at site/build.js parses lesson front-matter to produce a searchable catalog that highlights language diversity. This automation ensures the README's lesson table accurately reflects which languages are implemented—for example, marking Phase 01 lessons as "Python, Julia" while later phases may include all four languages.

Summary

  • Parallel implementations: Every algorithm appears in multiple languages, typically starting with Python and Julia, then expanding to TypeScript and Rust.
  • Strict dependency policies: Each language operates under std-lib-first constraints, with only vetted external libraries permitted.
  • Unified structure: Consistent code/, docs/, and tests/ directories across all lessons make navigation predictable regardless of language.
  • Automated validation: The audit_lessons.py script and CI pipeline ensure documentation accuracy and cross-language parity.
  • Bootstrap tooling: A Rust-based setup script verifies that learners have installed all four language runtimes before beginning coursework.

Frequently Asked Questions

How does the curriculum decide which languages to use for each lesson?

The curriculum selects languages based on which best illustrates the specific concept. Mathematical foundations typically start with Python and Julia due to their numerical computing strengths, while agent engineering and production systems include TypeScript and Rust. The front-matter in each lesson's docs/en.md file explicitly declares the supported languages, and the README maintains a master table tracking language availability across phases.

Why does the curriculum restrict external dependencies so strictly?

The std-lib-first policy forces learners to implement algorithms manually rather than importing solutions. According to the AGENTS.md specifications, Rust must use only standard library features, while Python may use numpy and torch only after manual implementations are complete. This constraint ensures students understand the underlying mathematics before using high-level abstractions.

Can I complete the curriculum knowing only one programming language?

While possible, the curriculum is designed for multi-language exposure. Each lesson's core concept is implemented identically across languages, so a Python developer can theoretically complete Phase 01 using only main.py files. However, the educational value comes from comparing how Julia handles Unicode operators versus Rust's type safety, so the authors recommend installing all four runtimes using the bootstrap checker in phases/00-setup-and-tooling/01-dev-environment/code/main.rs.

How does the repository ensure code quality across four different languages?

The project uses language-native testing frameworks combined with automated validation. Python uses unittest, TypeScript runs via npx tsx, Rust uses inline tests, and Julia employs @testset macros. The CI pipeline executes these separately, while audit_lessons.py verifies that every language listed in a lesson's documentation actually has corresponding source files in the code/ directory, preventing documentation drift.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →