19 Dec

Chapter 4: Carve Reality

There is no programming without abstraction.

Algebra is an example of abstraction. The symbol x stands not for a specific number but for some number. x is some special part of the numbers.

Words are abstractions. We carve out a piece of reality, separate it from the rest, and name it.

The name that is spoken is not the immortal name

When we speak, we string abstractions together to create a sentence or a paragraph that does what we want. Sometimes we don’t have a proper abstraction — we have to make up a new word. New words are born as slang; some words live past adolescence.

Programming is the same process as speaking a natural language. The “words” are different, the syntax is different, the process is the same. If you can talk, you can program.

A difference is that slang is created much more often in programming.

Repetition is the Cue

Wherever there is repetition, there is an opportunity for abstraction.

If you repeatedly sum up numbers and divide by how many numbers there are (we call that the mean), then you should make an abstraction. Create a routine for that and call it mean.

A programmer’s task is to:

  • spot repetitions
  • package each into the most appropriate abstraction

Sometimes it is easy to see the abstraction that will work best. Sometimes not.

Compression

You can think of programming as an exercise in compression.

When data are compressed, a code is created so that the actual data can be written more compactly. What’s done once has to stay, but repeated parts can be shrunk. Programming is similar.

Carve and compact.

Ally

  • Chapter 9: Verbalize and Nounalize
  • Chapter 54: Do Not Repeat Repeat Repeat

Next chapter

Back to the table of contents

Back to Tao Te Programming page

© Copyright - Burns Statistics