Build Your Own X — 从零构建一切
"What I cannot create, I do not understand." — Richard Feynman
基于 codecrafters-io/build-your-own-x(529K+ ⭐),精心整理的 200+ 篇「从零重建技术」教程合集。
Use this guide when someone asks
- "我想从零实现一个 XXX" / "I want to build a XXX from scratch"
- "怎么手写/手搓一个 XXX" / "How to recreate XXX"
- "想理解 XXX 底层原理" / "How does XXX work under the hood?"
- "build your own XXX" / "from scratch" / "byox"
- "不用框架/库,纯手写 XXX" / "No frameworks, just raw code"
When NOT to use
- Simple how-to-use guides for existing frameworks/libraries
- Pure theory discussions without coding
- Already-known standalone tutorials (this is an index, not a replacement)
How to Use
Step 1: Clarify what to build
Ask:
- What technology? (database, game, OS, language…)
- What language? (Python, Go, Rust, C, JS…)
- Time budget? (one afternoon vs. multi-week deep dive)
- Minimal (< 500 lines) or full-featured?
Step 2: Match a tutorial
Find the best match from the index below. Prioritize language + difficulty + domain.
Step 3: Guide through the tutorial
- Open the tutorial link, extract key steps and code snippets
- Plan the coding flow, guide the user step by step
- If there's a companion code repo, point them to clone it
- Verify compilation/execution at each step
教程索引 / Tutorial Index
🎮 3D 渲染器 (3D Renderer)
| 语言 | 教程 | 特点 |
|---|---|---|
| C++ | Ray Tracing in One Weekend | 经典入门,周末搞定 |
| C++ | TinyRenderer | 500 行 OpenGL |
| C++ | Physically Based Rendering | 教科书级 |
| C# / JS | 3D soft engine from scratch | 从 C# 到 JS 多语言 |
| Java / JS | Build your own 3D renderer | 从零光线追踪 |
| Python | A 3D Modeller | 500 Lines or Less |
| C++ | Rasterization: Practical Implementation | 光栅化实战 |
🤖 AI 模型 (AI Model)
| 语言 | 教程 | 特点 |
|---|---|---|
| Python | LLMs from scratch | 从零实现大语言模型 |
| Python | Diffusion Models for Image Generation | HuggingFace 官方 |
| Python | RAG from Scratch | LangChain 出品 |
⛓️ 区块链 / 加密货币 (Blockchain)
| 语言 | 教程 | 特点 |
|---|---|---|
| Go | Building Blockchain in Go | 系列教程 |
| Python | Learn Blockchains by Building One | 经典入门 |
| JavaScript | Naivecoin | <1500 行 |
| TypeScript | NaivecoinStake | PoS 版本 |
| JavaScript | Build your own Blockchain in JS | 纯 JS |
🗄️ 数据库 (Database)
| 语言 | 教程 | 特点 |
|---|---|---|
| Go | Build Your Own Database from Scratch | B+Tree → SQL,3000 行 |
| Go | Build Your Own Redis from Scratch | Redis 协议 |
| C | Let's Build a Simple Database | C 语言经典 |
| C++ | Build Your Own Redis from Scratch | Redis 实现 |
| JavaScript | Dagoba: in-memory graph database | 500L 系列 |
| Python | DBDB: Dog Bed Database | 500L 系列 |
| Python | Miniature Redis with Python | 迷你 Redis |
| Rust | Build your own Redis client and server | Tokio 官方 |
🐳 Docker
| 语言 | 教程 | 特点 |
|---|---|---|
| C | Linux containers in 500 lines | 纯 C |
| Go | Build Your Own Container Using <100 Lines of Go | 100 行 Go |
| Python | A workshop on Linux containers | 重写 Docker |
| Shell | Docker in ~100 lines of bash | 最简容器 |
🕹️ 模拟器 / 虚拟机 (Emulator / VM)
| 语言 | 教程 | 特点 |
|---|---|---|
| C | Write your Own Virtual Machine | LC-3 VM |
| C | Writing a Game Boy emulator, Cinoop | GameBoy |
| JavaScript | GameBoy Emulation in JavaScript | GameBoy in JS |
| Python | Chip 8 Emulator/Interpreter | Chip-8 |
| Rust | 0dmg: Learning Rust by building a Game Boy emulator | GameBoy in Rust |
| C++ | NES Emulator From Scratch | NES 视频系列 |
🎮 游戏 (Game)
| 语言 | 教程 | 特点 |
|---|---|---|
| C | Handmade Hero | 传奇级,从零写游戏 |
| C | How to Program an NES game in C | NES 游戏 |
| C | On Tetris and Reimplementation | 俄罗斯方块 |
| JavaScript | 2D breakout game using Phaser | MDN 官方 |
| JavaScript | How to Make Your First Roguelike | Roguelike |
| Python | Pygame Tutorial | Pygame 入门 |
| Python | Roguelike Tutorial Revised | Roguelike 经典 |
| Rust | Roguelike Tutorial in Rust + tcod | Rust + tcod |
🔧 Git
| 语言 | 教程 | 特点 |
|---|---|---|
| JavaScript | Gitlet | Git in JS |
| JavaScript | Build GIT - Learn GIT | 学习 Git 内部 |
| Python | Write yourself a Git! | 最完整 |
| Python | ugit: Learn Git Internals by Building Git Yourself | 精简易懂 |
| Python | Just enough of a Git client | 最小 Git |
🧠 神经网络 (Neural Network)
| 语言 | 教程 | 特点 |
|---|---|---|
| Python | A Neural Network in 11 lines of Python | 11 行入门 |
| Python | Build Deep Learning From Scratch | 34 阶段重写 PyTorch |
| Python | Neural Networks: Zero to Hero | Karpathy 视频 |
| Python | SlowTorch | 纯 Python 实现 PyTorch |
| Go | Build a multilayer perceptron with Golang | Go 写 MLP |
| JavaScript | Neural networks from scratch for JS linguists | JS 党入门 |
💻 操作系统 (Operating System)
| 语言 | 教程 | 特点 |
|---|---|---|
| C | OS: From 0 to 1 | 电子书 |
| C | The little book about OS development | 经典小书 |
| C | Roll your own toy UNIX-clone OS | 类 UNIX |
| C | Kernel 101 – Let's write a Kernel | 入门内核 |
| C | Kernel 201 – Keyboard and screen support | 进阶内核 |
| Rust | Writing an OS in Rust | Rust OS 圣经 |
| Rust | Add RISC-V Rust Operating System Tutorial | RISC-V |
| Assembly | Writing a Tiny x86 Bootloader | Bootloader |
| C++ | Write your own Operating System | 视频系列 |
| (any) | Linux from Scratch | 终极挑战 |
📝 编程语言 (Programming Language)
| 语言 | 教程 | 特点 |
|---|---|---|
| (any) | mal - Make a Lisp | 68 种语言实现 Lisp |
| C | Build Your Own Lisp | 1000 行 C |
| Go | The Super Tiny Compiler | 最小编译器 |
| JavaScript | The Super Tiny Compiler | JS 版 |
| JavaScript | How to implement a programming language in JS | PL 入门 |
| Python | Let's Build A Simple Interpreter | 解释器系列 |
| Python | From Source Code To Machine Code | 编译器 |
| Python | A Python Interpreter Written in Python | PyPy 式 |
| Haskell | Write Yourself a Scheme in 48 Hours | Scheme 48h |
| Java | Crafting Interpreters | 神书 |
| Rust | Learning Parser Combinators With Rust | Parser Combinators |
| TypeScript | Build your own WebAssembly Compiler | WASM |
🔍 正则表达式引擎 (Regex Engine)
| 语言 | 教程 | 特点 |
|---|---|---|
| C | A Regular Expression Matcher | Rob Pike 经典 |
| JavaScript | Build a Regex Engine in <40 Lines of Code | <40 行 |
| Python | Build Your Own Regex Engines | NFA/DFA/回溯 |
🔎 搜索引擎 (Search Engine)
| 语言 | 教程 | 特点 |
|---|---|---|
| Python | Building a search engine using Redis | Redis 搜索 |
| Python | Building A Python-Based Search Engine | 视频 |
🐚 Shell
| 语言 | 教程 | 特点 |
|---|---|---|
| C | Tutorial - Write a Shell in C | C Shell 经典 |
| C | Writing a UNIX Shell | UNIX Shell |
| Go | Writing a simple shell in Go | Go Shell |
| Rust | Build Your Own Shell using Rust | Rust Shell |
🌐 Web 服务器 (Web Server)
| 语言 | 教程 | 特点 |
|---|---|---|
| Node.js | Build Your Own Web Server From Scratch In JavaScript | 分步指南 |
| Node.js | lets-build-express | 从零写 Express |
| Python | Let's Build A Web Server. | 经典系列 |
| Python | Web application from scratch | 从头开始 |
| Ruby | Building a simple websockets server from scratch in Ruby | WebSocket |
🖥️ 前端框架 / 库 (Front-end Framework)
| 语言 | 教程 | 特点 |
|---|---|---|
| JavaScript | WTF is JSX (Let's Build a JSX Renderer) | 理解 JSX |
| JavaScript | Build your own React | 手写 React |
| JavaScript | Gooact: React in 160 lines of JavaScript | 160 行 React |
| JavaScript | Build Yourself a Redux | 手写 Redux |
| JavaScript | Building a frontend framework | 完整框架 |
| JavaScript | How to write your own Virtual DOM | 虚拟 DOM |
📡 网络栈 (Network Stack)
| 语言 | 教程 | 特点 |
|---|---|---|
| C | Beej's Guide to Network Programming | 网络编程圣经 |
| C | Let's code a TCP/IP stack | TCP/IP |
| Ruby | How to build a network stack in Ruby | Ruby 网络 |
🖊️ 文本编辑器 (Text Editor)
| 语言 | 教程 | 特点 |
|---|---|---|
| C | Build Your Own Text Editor (Kilo) | 经典 kilo |
| Rust | Hecto: Build your own text editor in Rust | Rust 编辑器 |
🧩 模板引擎 (Template Engine)
| 语言 | 教程 | 特点 |
|---|---|---|
| JavaScript | JS template engine in just 20 lines | 20 行 |
| Python | A Template Engine | 500L 系列 |
🧰 命令行工具 (Command-Line Tool)
| 语言 | 教程 | 特点 |
|---|---|---|
| Go | Build a CLI app with Go: lolcat | Go CLI |
| Rust | Command line apps in Rust | Rust CLI 书 |
| Node.js | Create a CLI tool in JavaScript | JS CLI |
🔩 其他 (Uncategorized)
学习路线 / Learning Pathways
🟢 入门 (Beginner) — 周末速成 (Weekend projects)
适合刚入门、想快速有成就感 / Quick wins:
- Shell (C) — 一个下午
- Regex Engine (JS, <40 行) — 一小时
- Neural Network (Python, 11 行) — 一小时
- Blockchain (Python) — 一个下午
- Web Server (Python/Node.js) — 一个下午
🟡 进阶 (Intermediate) — 深入理解 (Deep understanding)
有基础、想深入系统 / Solid foundations, deeper systems:
- Git (Python) — 1 天
- Database (Go/C) — 2-3 天
- Container/Docker (Go) — 1 天
- 3D Renderer (C++, Ray Tracing) — 周末
- Emulator (C, Chip-8) — 周末
- Programming Language (mal Lisp) — 3-5 天
🔴 专家 (Expert) — 终极挑战 (The deep end)
推自己到极限 / Push your limits:
- Operating System (C/Rust) — 数周到数月
- Compiler (Crafting Interpreters) — 2-4 周
- Game Engine (C, Handmade Hero) — 数月
- Browser Engine (Rust) — 数周
- Linux from Scratch — 数天到数周
小贴士 / Tips
- 从入门路线开始建立信心,再迈入进阶领域
- 每个项目建一个 Git 仓库记录进展
- 卡住时直接看教程评论区/Issues
- 有多个语言版本时先选你最熟悉的那门

