Build Your Own x From Scratch Books

Level up your coding skills. By recreating tech from scratch. With step-by-step guides.

The what & why of “build your own X”

Pick a tool or software and try to recreate it by coding it from scratch. “From scratch” means not just glueing components together, but taking the time to learn how stuff works.

Why take on such challenges? The benefits?

  • Project-based learning. CS topics such as data structure and operating systems are overlooked due to lack of practice. And best practices are based on real-world projects.
    • Students without experience can solidify their learning.
    • Developers without CS education can discover the gap.
  • Master fundamentals. Not all knowledge is equally valuable, and some is further devalued by AI, such as “how to do X in framework Y”. All “from scratch” projects are connected to CS fundamentals. Use them as a guide to take your skills to the next level.
  • Advance your career. Prepare for more technical, system-y work! Not every job is about CRUD, and more options are nice. These projects are also nice things to put on a resume, especially if you have no experience.
  • Computers are fun. Partly because you can study, understand, and recreate almost any software. Projects like this are flexible, you can always pick a topic and go deeper.

Build Your Own Redis with C/C++

Network programming, data structures and low-level C/C++.

  • Why build Redis? Data structures and systems programming are what application developers lack. Redis is a perfect medium to acquire the knowledge & experience.
  • Start from scratch? A quote from Feynman: “What I cannot create, I do not understand”. Learn by doing instead of reading.
  • Why C? C was, is, and will be widely used for infrastructure or low-level software. Learn C today instead of chasing fads, and you'll appreciate it in the future.
  • Why a book? The real Redis is a large code base with lots of details. We'll only touch on the essentials via small steps.
The full book & C++ code is free on the Web.
Support us by buying the eBook/paperback.

Build Your Own Database From Scratch

Learn databases from the bottom up by coding your own, in small steps, and with simple Go code (language agnostic).

  • Atomicity & durability. A DB is more than files!
    • Persist data with fsync.
    • Crash recovery.
  • KV store based on B-tree.
    • Disk-based data structures.
    • Space management with a free list.
  • Relational DB on top of KV.
    • Learn how tables and indexes are related to B-trees.
    • SQL-like query language; parser & interpreter.
  • Concurrent transactions with copy-on-write data structures.
Part I on basic KV is free on the Web.
The full book is available in eBook/papaback.

From Source Code To Machine Code

Build a compiler to learn how programming languages work. Use low-level assembly to learn how computers work.

Walks through a minimal yet complete compiler. Compiles a static-typed language into x64 ELF executables.

Step by step Python code (language agnostic):

  1. Simple interpreter. Get your own language up and running.
  2. Bytecode compiler. Virtual computer within real computer.
  3. x64 assembly & instruction encoding. Learn the real machine.
  4. Translate bytecode to x64 code. Bridge virtual and real.
  5. Generate binary executables. Put it all together.
Part I on interpreters is free on the Web.
The full book is available in eBook/papaback.

Build Your Own Web Server From Scratch In Node.JS

Learn network programming and HTTP by coding a web server.

  • Network programming.
    • Socket API and the event loop in Node.JS.
    • Protocol design and implementation.
    • Promises and async/await.
  • HTTP in detail. Semantics and syntax.
  • Beyond coding exercises.
    • Discusses the gap between toys and production.
    • Overlooked tech, backpressure, resource management, etc.
  • WebSocket extension.
    • Message-based protocol; another paradigm.
    • Introduction to concurrent programming.
Free part I on basic HTTP servers.
The full book is available in eBook/papaback.