What Programming Languages Are Used in AI Engineering from Scratch?

The AI Engineering from Scratch curriculum by rohitg00 implements hands-on AI lessons in five programming languages—Python, Rust, Julia, TypeScript, and JavaScript—each chosen to demonstrate specific engineering principles without hidden library abstractions.

The rohitg00/ai-engineering-from-scratch repository takes a polyglot approach to teaching artificial intelligence from first principles. Understanding which programming languages are used in AI Engineering from Scratch reveals a deliberate pedagogical strategy: each language targets a specific computational layer, ensuring learners understand both high-level model orchestration and low-level algorithmic mechanics. All implementations adhere to a strict dependency allowlist defined in AGENTS.md, keeping the focus on foundational concepts rather than framework magic.

Python: The Primary Teaching Language

Python serves as the workhorse for the majority of deep-learning and data-processing lessons. It powers tokenizers, model training loops, safety-gate pipelines, and end-to-end capstone projects that require rapid iteration and readable syntax.

The repository demonstrates production-grade patterns in phases/19-capstone-projects/87-end-to-end-safety-gate/code/main.py, where Python orchestrates model inference alongside safety guardrails. Typical implementations favor explicit loops and minimal dependencies over heavyweight framework calls.


# file: examples/python_token_counter.py

from pathlib import Path

def count_tokens(text: str) -> int:
    # Very naive tokeniser – matches the educational style of the repo

    return len(text.split())

if __name__ == "__main__":
    txt = Path("sample.txt").read_text()
    print(f"Tokens: {count_tokens(txt)}")

Rust: Systems Programming for Performance

Rust handles low-level, performance-critical components where memory safety and zero-cost abstractions matter. The curriculum uses Rust for byte-pair encoding (BPE) tokenizers, quantization routines, and inference optimizations that would be impractical to implement safely in raw C.

In phases/10-llms-from-scratch/01-tokenizers/code/bpe.rs, learners build a tokenizer from scratch using hash maps and string manipulation without relying on external NLP crates.

// file: examples/rust_bpe.rs
use std::collections::HashMap;

/// Very small BPE step – mirrors the repository’s `bpe.rs` implementation.
fn merge_pair(pair: (&str, &str), vocab: &mut HashMap<String, usize>) {
    let merged = format!("{}{}", pair.0, pair.1);
    *vocab.entry(merged).or_default() += 1;
}

Julia: Mathematical Foundations

Julia is deployed for mathematically intensive lessons covering linear algebra, calculus, and probability. Its syntax allows vectorized operations to mirror textbook mathematical notation, making it ideal for teaching the numerical foundations of machine learning.

The file phases/01-math-foundations/01-linear-algebra-intuition/code/vectors.jl demonstrates native linear algebra operations without wrapper libraries.


# file: examples/julia_vectors.jl

using LinearAlgebra

v = [1.0, 2.0, 3.0]
w = [4.0, 5.0, 6.0]

println("dot(v, w) = ", dot(v, w))
println("v + w = ", v .+ w)

TypeScript: Type-Safe Multi-Agent Systems

TypeScript powers the multi-agent, tool-calling, and Model Context Protocol (MCP) projects. The language’s static type system provides safety guarantees for server-client architectures where message contracts must be strictly enforced.

All TypeScript modules are compiled with Node.js 20+ and run via the standard library, avoiding heavy runtime dependencies. The entry point at phases/19-capstone-projects/10-multi-agent-software-team/code/ts/src/index.ts illustrates how type-safe message passing enables reliable agent coordination.

// file: examples/ts_mcp.ts
export interface Message {
  role: "user" | "assistant";
  content: string;
}

export const hello: Message = {
  role: "assistant",
  content: "Hello from the MCP server!",
};

JavaScript: Infrastructure Tooling

JavaScript supports auxiliary tooling rather than core lessons. It underpins the static site generator and build scripts that compile the curriculum’s documentation UI.

The site/build.js file processes lesson metadata and generates static assets, demonstrating how modern ES modules handle file system operations without external build tools.

// file: examples/site_build.js
import { writeFileSync } from "fs";

const data = { version: "1.0.0", generated: new Date() };
writeFileSync("site/data.js", `export const info = ${JSON.stringify(data)};`);

Educational Design Philosophy

The multilingual structure follows the repository’s dependency allowlist policy documented in AGENTS.md. By restricting external libraries, the curriculum forces implementations to expose algorithmic details—learners see the actual matrix multiplication in Julia, the memory layout in Rust, and the message serialization in TypeScript. This approach ensures that AI Engineering from Scratch programming languages are not just tools, but lenses through which underlying computer science principles become visible.

Summary

Frequently Asked Questions

Is Python the only language required to understand the machine learning concepts?

No. While Python handles most high-level machine learning workflows, the curriculum deliberately uses Rust for performance-critical tokenizers and Julia for mathematical foundations. Completing all lessons requires reading code in all five languages, though the core concepts are explained independently of language syntax.

Why does the curriculum use Rust instead of C++ for low-level components?

Rust’s ownership model provides memory safety guarantees without a garbage collector, making it ideal for teaching low-level optimizations like byte-pair encoding without risking segmentation faults. The bpe.rs implementation demonstrates systems programming concepts with compiler-enforced safety rules that are pedagogically clearer than equivalent C++ code.

Can I run the TypeScript implementations with older Node.js versions?

No. According to the source code specifications, all TypeScript modules target Node.js 20+ and rely on modern standard library features. Running earlier versions may result in import errors or missing API support for the file system and networking operations used in the multi-agent projects.

Does the JavaScript code use any frontend frameworks like React or Vue?

No. The JavaScript in site/build.js is pure Node.js code used for static site generation. The repository avoids frontend frameworks to maintain the dependency-free philosophy outlined in AGENTS.md, relying instead on vanilla JavaScript for build tooling and data preparation scripts.

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 →