Skip to content

Try “polymorphism”, “TCP handshake” or “git rebase”.

    Computer Basics / How Computers Work

    The Whole Story

    The whole module retold as one story — no new facts, a fast revision of How Computers Work.

    Extra: Revision3 min read

    A computer is billions of light switches (bits, Ch 1). Alone, a switch means nothing — but switches in a row can count (binary, Ch 2): eight of them make a byte that holds 0 to 255, and every extra switch doubles the range. Long rows of 0s and 1s are painful to read, so humans write them in hex, four switches per digit (Ch 3).

    Because a bit pattern has no meaning of its own, everything depends on agreements (Ch 4): two's complement makes some patterns negative (and makes Java's int wrap to −2,147,483,648 when it overflows); floating point squeezes fractions into 64 bits at the cost of tiny errors (so no == on floats and no floats for money); Unicode gives every character a number, and UTF-8 turns that number into 1–4 bytes (so Hi 😀 is 4 characters but 7 bytes); and three bytes of red, green and blue make the orange of our score.

    The cook (CPU, Ch 5) follows one tiny recipe step at a time — fetch, decode, execute — billions of times per second, with a small countertop of registers and several cooks (cores) working at once. The ingredients sit on a ladder of storage (Ch 6): tiny fast caches, bigger slower RAM that forgets everything when power goes, and huge slow disks that remember. Grabbing a whole box at a time (cache lines) is why arrays beat linked lists in practice. Every byte in RAM has a house number (address, Ch 7), and a reference is just a note holding one of those numbers.

    The code we write is not something the cook understands. It must be translated (Ch 8): ahead of time by a compiler, live by an interpreter, or — like Java — into portable bytecode that a virtual machine runs and speeds up with a JIT. Once a program is copied into RAM and running, it is a process.

    And when you type Hi 😀 and press Save (Ch 9), all of it happens in a fraction of a second: key signal → operating system → bytes in RAM → CPU instructions → bytes on the SSD → pixels on the screen.

    The one piece this file kept pointing to but never explained is the operating system — the manager that loads programs, shares the CPU between them and guards the disk. That's the next file.