Programs must be written for people to read, and only incidentally for machines to execute
This quote is from Harold Abelson and I am obsessed with it (I made a poster out of it for our offices).
Surprisingly, not everyone agrees with this quote. I want to explore why this is.
I think most people who disagree with the above quote confuse computer systems with computer programs.
- Computer programs are written instructions that can be executed by a computer to perform a specific task.
- Computer systems are computer(s) performing computer programs
They believe the quote is saying that computer systems are written for humans to understand and incidentally for machines to execute. This last statement is false. Computer systems exist for humans to interact with.
Comparing software construction with building construction
Computer programs are to computer systems what blueprints are to buildings. The computer program specifies the intended behaviour of the computer system. The blueprint specifies the intended structure of the building.
There are roughly 2 steps in creating a computer system or a building:
- Step 1 is determining the specifications of the system. For computer systems this is writing the computer program. In building construction it is creating the blueprints.
- Step 2 is building the system to satisfy the specifications. For computer systems this is usually a trivial step because it is automated. In the case of buildings this step is not automated yet.
Readability of the blueprints is crucial in both steps in building construction. Humans need to understand the blueprints so they know what they will get and humans need understand the blueprints so they can build it. Readability is therefore needed in step 1 and step 2.
On the other hand, readability of the computer program is only important in step 1 as step 2 is completely automated.
Could we therefore argue that it is less important for a computer program to be readable? If computer systems don't need to change then yes. You can always use the computer system and determine if you are happy with it.
If it does need to change then you absolutely need to understand the existing specifications (aka. computer program) of your computer system.
You can probably renovate a house without its initial blueprint. You cannot modify an existing computer system without its corresponding computer program.
This is common sense so far.
What can we take away from this in our day-to-day as programmers?
One possible takeaway is to emphasize readability in parts of your system that is likely to change and neglect readability in parts of your system that do not need frequent change.
However, if the computer program is not readable, how sure can you be the computer system will behave as intended?
You can try out the computer system and see if it behaves as intended. But how sure are you it will behave as intended in all situations?
This last question reminds me of my second favourite quote in computer science