Software Fundamentals
How a computer actually runs a program, from the bit to the network, for people who will direct the software rather than type it.
Most people who build software today work many layers above the machine. A line of Python stands on an interpreter, which stands on a compiler’s output, which stands on an operating system, which stands on a processor that is itself an elaborate fiction kept up by billions of switches. Each layer promises something simple and hides something costly. That is what makes them useful, and it is also why so much software is slower, stranger or more fragile than its authors expected.
This book goes through those layers from the bottom up. It starts with what a bit is and how a pattern of them comes to mean a number or a letter, builds a processor out of switches, and then climbs: the instructions a processor understands, the memory that cannot keep up with it, the tricks a modern core plays to run fast anyway, the programs that turn source code into something it can run, the operating system that shares the machine out, the files that outlive a power cut, the threads that run at once, and the network that carries bytes between machines. It ends with the limits: what can be computed at all, what can be computed fast, and how to estimate a design’s cost before anyone builds it.
One small program goes with the reader all the way: wc, which counts the words in a file and sends the count to another machine. Each chapter asks what one layer does to it.
The reader this book has in mind will spend more time judging code than writing it, increasingly code written by an agent. Judging well needs a working model of the machine underneath: what is cheap, what is expensive, what is impossible, and why. That model is what the book is for. It assumes no programming beyond being able to read a short Python function, and it defines every term where it first appears.
Contents
-
1 Bits and what they mean
Everything a computer holds is a pattern of bits, and a pattern means nothing until something decides how to read it.
-
2 From switches to a computer
A processor is built from one idea, a switch that controls another switch, repeated a few billion times.
-
3 The machine’s language
The instruction set is the contract between hardware and software, and reading it is how you see what a program really does.
-
4 Memory and caches
The processor can compute far faster than memory can feed it, and caches are the elaborate answer.
-
5 Inside a modern processor
A modern core runs hundreds of instructions at once and guesses the future; the simple fetch-decode-execute loop is a story it keeps up for software’s sake.
-
6 From source code to running program
Between the text a programmer writes and the instructions a processor runs stand compilers, linkers, loaders and interpreters, each adding something and costing something.
-
7 The operating system
The operating system is a program that stands between every other program and the hardware, sharing it out and keeping programs from harming each other.
-
8 Virtual memory
Every process believes it owns all of memory; the hardware and kernel maintain that illusion page by page.
-
9 Storage and files
Memory forgets when the power goes; storage remembers, slowly, and making it remember correctly is harder than it looks.
-
10 Concurrency
Doing several things at once is the only way left to go faster, and the easiest way to write bugs that appear once a month.
-
11 Networks
How a byte leaves one machine and arrives at another, across a world of links that lose, reorder and delay it.
-
12 Limits and costs
What can be computed, what can be computed fast, and how to know before building which side of the line a design falls on.