Chapter One · Thinking in Cost
Thinking in Cost
The habit the whole book runs on: before asking how fast the machine is, ask what the operation costs and how that cost grows. Six topics turn the stopwatch into a count of steps, compress the count into Big-O, put numbers on the classes that end projects, separate an average from a guarantee, and add memory as the second price of every algorithm.
Every performance incident has a moment when somebody says "but it was fast in testing". It was. The test had a thousand rows, production has two million, and the code's cost grew with the square of the rows. Nothing about the machine changed. The procedure did exactly what it was written to do, and the only thing missing was the question nobody asked before it shipped: what does this cost when the input grows?
This chapter makes that question a reflex. It starts from what computer science actually studies and meets Lantern, the library search service the book returns to wherever a real system makes an idea clearer. It replaces timing with counting, then compresses counts into Big-O, the notation that throws away everything except how cost grows. It gives each growth class a number at a thousand and at a million items, separates the four ways a cost can be stated, and ends on memory, the price with a hard ceiling.
No proofs appear here or anywhere else in the book. Everything is arithmetic and curves, and every topic ends on what its idea costs in a system you already run.