Our brain is an amazing organ, capable of truly astounding feats of abstraction and generalization, particularly when compared to a computer. On the other hand, it measures up pretty poorly when it comes down to managing a lot of information at once. Ayn Rand, a 20th century philosopher, described this phenomenon as Crow Epistemology with the following story (paraphrased).
Imagine there are a bunch of crows sitting in the tree-tops at the edge of a forest. A pair of hunters pass them on their way into the forest, and all the crows get really quiet. One hunter comes out alone, but the crows stay quiet because they know there’s still another one in the forest. At little while later, the second hunter comes out, and as soon as he’s out of sight, the crows relax and start cawing again.
Now, imagine that a group of 20 hunters goes into the forest. The crows get all quiet, just like before. After a while, 15 hunters come out again. As soon as they’re out of sight, the crows start up with their cawing again. The crows could keep track of two hunters, but 20 was just too many for them to track by sight.
Of course, humans have the same problem. To address this, we create abstractions (like numbers) which allow us to group things together and keep track of them as a single unit. In our example, a boy sitting at the edge of the forest could simply count the hunters, and just remember one thing (the number 20). That way, he could easily know whether all the hunters had left the woods or not.
It turns out, programming is a lot harder than counting, and to do it, we need to keep all kinds of information stuffed in our heads. Naturally, the rules are no different, so we, as programmers, use lots of abstractions to keep everything straight. No one could possibly think about all the electrical signals racing around in a computer while they were designing a game. Even when designing a simple game, we need to break the program up into pieces, and complete each piece one at a time, and then stitch the parts together.
This process of using higher and higher abstractions to manage complexity is known as unit economy. By grouping complex things together into a single unit, we can forget about how it works, and just remember what it does. You don’t have to remember how a transistor works to understand what it does, just as you don’t need to remember how to implement a hash table to understand what it does.
The concept of unit economy is behind everything we do in our daily work as programmers. Not too surprisingly, abusing a reader’s unit economy is the foremost way to make your code unreadable. I’ll have more to say on actually applying this principle in future posts.
For further reading:
- Leroy, Charles Georges. “Letter VII. On the Instinct of Animals. The Intelligence and Perfectibility of Animals from a Philosophic Point of View: With a Few Letters on Man”. pgs 125-126. (Google Books)
- Miller, George. “Magical Number Seven, Plus or Minus Two…” (Wikipedia)
- Rand, Ayn. “Introduction to Objectivist Epistemology” (Amazon)