Optimise for Clarity

Before we start, here’s the big theme of this book:

Programming is all about explaining to another human what the computer happens to be doing at any given moment. As a by-product, it also tells the computer what to do.

The reason this is so important is that what the computer actually runs is almost incomprehensible to anyone.

As an example, if I write this:

1 clearScreen();

you can understand that I want the computer to clear everything off the screen, leaving it blank.

The computer can’t though. It’s as dumb as rocks. Literally. Silicon chips are made of Silicon Dioxide - Sand.

We need to pass this code through some kind of translator to turn this into the language of the computer. One that looks nothing like English.

One of my old computers would need something like this:

1   LD HL, 4000H  00100001 00000000 01000000
2   LD DE, 4001H  00010001 00000001 01000000
3   LD BC, 6143   00000001 11111111 00010111 
4   LD (HL), 0    00110110 00000000
5   LDIR          11101101 10110000

Where the assembly language on the left was still a human-readable form. The binary on the right was what that computer ran on its Z80A microprocessor.

I know which one I like better.

The art of programming is making programs clear. Readable. Easy to skim read. No tricks.

It is the difference between having to read all that binary and work out that it meant ‘clear the screen’, compared to reading ‘clearScreen()’.

In a working professional team, nobody has the time, money, or desire to do that. Ever.

This book is all about helping you create code that both you and your colleagues can understand.