Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 06 · How Computers Work · Build the machine's software · about 18 min to read

Play it as a journeyTutor comes with a plan

From text to machine code: compilers, interpreters and the JIT

How Code Becomes Execution
How Code Becomes Execution · Open board

The road from the words you type to the bytes the chip runs. This lesson walks that road one stop at a time and builds a small version of every stop.

Before you start. The CPU (fetch-decode-execute, the ISA, assembly) gave you a chip that fetches an instruction, decodes it and runs it, and understands nothing else. How Code Becomes Execution (compilers, stack & heap) gave you the two big ideas: a compiler translates the whole program before it runs, and an interpreter translates one step at a time while it runs. Build a stack machine built the small program that reads a list of numbers as instructions. This lesson opens the translator itself.

Lesson 32 of 41 in How Computers Work

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • The problem: the chip cannot read x * (2 + 3)
  • The lexer: characters become tokens
  • The parser: tokens become a syntax tree
  • The interpreter: walk the tree
  • The IR: a flat list of one-step instructions
  • The optimisation pass: do the sums before the program runs
  • The JIT: compile only what runs again and again
  • The pipeline as a picture
  • What the toy leaves out
  • A real JIT warming up
  • Real engines: tiers
  • Trade-offs

Terms it explains: token, lexer, syntax tree, parser, interpreter, intermediate representation, IR, constant folding, optimisation pass, JIT compiler, hot, Ahead of time, Interpreter only, JIT, Two tiers, AST, buffer overflow, bytecode, CALL/RET, compiler, dereference (*), GC, heap, linker, memory leak, pointer, segfault, stack, stack frame, stack overflow, use-after-free / dangling pointer.

Review How Computers Work