I'm outside walking the dog; the air is cool and calm. It is a nightly ritual -- generally occurring right after watching the news -- giving me time to mull over the days issues. I'm not sure what it is about being alone on a cold dark street, wandering around leashed to 65 pounds of pure panting energy but my mind wonders. The dog pulls, we twist and turn down various streets and gradually my thoughts fall into place. They began taking a shape all their own.
Claude Shannon delved into the nature of information and rolled it into a comprehensive theory. He might have started with wondering about how few bits you really needed to represent specific data. Building it up based on simple questions like that. Information Theory is a incredibly important branch of mathematics that has helped shape the foundations of software.
In the same way that he examined how little we need, I've often come to contemplate on how little 'code' we need to represent a large sequence of operations. In a sense, how small an expression do you need to clearly express some underlying functionality?
The dog tugs hard, as a cat goes screeching by. It jars me back into the scene. Some of the neighborhood cats are terrified when she approaches, while others actually head straight for the dog as if they were willing to confront her directly. Generally, for the crazy ones I intervene and change course, allowing the cat to win. Cats, you see, are not to be messed with. They may be a faction of the size of a dog, but they go at life with far more determination.
Falling back into my line of thinking, I decide to steal an idea from Economics, where they love to talk about the "economies of scale". I like this saying, but I think the term "economies of expression" suits my current line of thought. My definition for this, flipping it a bit from its origins, would have to be something like: "reductions in syntactic expression for a set of underlying actions can produce decreases in complexity". You get -- if I can manage to clarify it -- less complexity in the system if you can encapsulate your ever-increasing sets of steps into smaller and smaller expressions. Each line of code built up, should pack more of a punch then the earlier ones. If the expressions are still recognizably associated with the steps, then the complexity is reduced.
A great example of this is Graph Viz. It is a little language interpreter that draws complex graphs. It has a small simple syntax that quietly hides its full expressive power. It is amazingly broad in its capabilities, yet stunningly simple in execution. A great example of elegance.
We should seek solutions that have these characteristics. However, we often expand the interfaces instead of refactoring them. To work with the bloat, you need more code to express less underneath. It is the opposite of elegance.
When I develop, I am always aware of how I am building layers onto top of each other. In each new layer, the expression is smaller, but the functionality is broader. Inside of writing a program, I'm often just building a toolkit in which the final program can be expressed as a small set of the axioms. If well-balanced and tight, the higher abstractions can be combined to form ever increasing higher abstractions. Over the life of the project, you should be developing the ability to specify a great deal, with an ever-decreasing amount of code. Layer on layer you build up the capabilities of the system. It becomes easier to add more as the code grows, not harder.
That is what I mean by leveraging the economies of expression. The earlier work makes the future work easier. As it progresses, I can express a complicated set of tasks with a minimal amount of syntax and still have the flexibility to apply it to related tasks. I build upwards, often by employing abstractions, but definitely by encapsulating the details -- completely -- below.
The code gets easier to write as the project matures. The progress is faster. We can add more functionality, more correctly, and in less time; building on our foundations as we go.
This time, my dog sees a raccoon in a tree and she goes crazy. She is jumping up and down, making a racket and looking wild. It is a quiet area, late at night so I often worry that her freaking out is making enough noise to disrupt people. I've never been one to enjoy rocking the boat without a reason; but there is little I can do to calm her down. She sees the presence of this hairy scavenger as a worthy cause; making a Tasmanian Devil sort of sound effect as her hair stands on end while bouncing into the air in a sort of frenzy. It could be a scary site, except that I know she is really just a big cream-puff underneath. All blow and no show, so to speak. If that raccoon turned and faced her, she'd be just as happy changing course and finding something else to bark at for the night.