[Analogy of some yogurt fermentation process where old yogurt is used to make new yogurt].

Fermentation is similar to building compilers. New languages are written with old languages.

  1. Algol 60 was extended to create the language AED.
  2. AED was used to write the first BCPL compiler.
  3. BCPL was used to write the first B compiler
  4. B was used to re-implement the B compiler
  5. The B langauge/compiler was iteratively transformed into the C language/compiler.

The typical "hello world" operating system starts with the C language, the fancy yogurt. We plan to create our yogurt from scratch.

Goals

While asking for advice on how to write this tutorial, my sister provided me with a great analogy for what we're trying to do: build a ship.

Many tutorials walk through which nails to put into which board of woods, explaining what's being built as the ship comes together.

In this tutorial, I hope to teach not just how to build a ship, but how ships are built, similar to what nand2tetris does. I plan to describe what makes a ship float, how a particular ship design fulfils those requirements, and the necessary woodworking skills.

The Plan

Earlier, we read that the B language/compiler was iteratively transformed into the C language/compiler. We plan on going through a similar process to elevate ourselves from machine code to a janky high-level language.

Once we implement a hacked-together high-level language, we'll rewrite the language's compiler in itself, adding features such as useful error reporting.

Once we have a non-painful language to work with, we'll begin implementing user-facing code, our end goal being to build a gemini client & server.

Long-term Goals

Setting up our Software

For the time being, this book is written for users of Linux and macOS. The Windows Subsystem for Linux should also work.

We'll use Nix to manage our software. Once Nix is installed, download the book's source code repo and run nix-shell.

git clone https://github.com/aaronjanse/os-book
  cd os-book
  nix-shell

You should be put in a bash shell with all the required software installed (in that shell only; none of the rest of your system is dirtied). This shell includes a patched version of qemu, and aliases binify & emulate to make your life easier.