Wednesday, November 4, 2009

Real World Examples

I'm a software engineer by trade and in my studies I learned about a programming language called Prolog. Unlike most programming languages, which are written as a sequence of events, with Prolog you define a goal and let the computer figure out how to accomplish it. It’s a fascinating approach to programming, but most of the examples looks something like this:

dog(spot). dog(rex). cat(tom). cat(sheba).

animal(X) :- dog(X).

animal(X) :- cat(X).

?- animal(Y).

spot ;

rex ;

tom ;

sheba ;

?-

I won't ask you to try to make sense of that, unless you really want to. Essentially, given a list of named dogs and cats, and a definition that specifies that dogs and cats are animals, the computer will return the names of all animals. I’m sure I find that more impressive than you do, but even I have to wonder what is so great about being able to get the complete list of animals in this way. It demonstrates the language, but it doesn’t really tell us why we would want to use the language.

The other day, I happened to see a real world example. In the real world example, given a list of airline flights, the program could find all of the connecting flights required to get a traveler from one location to another. That’s not extremely difficult a programmer to accomplish without Prolog, but I could see how it would be easier with Prolog and that made me consider how I could put it to use. But most true real world examples are too large and too complicated to cover in detail.

What does that have to do with writing? you might ask. Often, we see rules about things we should or shouldn’t do when we write. The person talking about it probably has a specific example in mind, but they don’t give us a real example. Instead, they scale it down to a writing sample that is at best a few paragraphs long. We are then asked to make some assumptions about what the rest of the text looks like, or would look like if it were complete. But the rules don’t scale well. We handle many things differently when we write a novel than how we do things when writing a short story. Something that would be considered an info dump in a novel may be perfect for a two paragraph story. Show, don’t just tell, they say for novels, but if the story is a page long, you’d better tell, not show, if you want to fit the whole thing in. This produces a problem because people look at the examples and what they glean from the example may not equate to the real problem. People think they understand the problem and the solution, but when they try to apply it to a larger work, they mess it up because what they learned from the example isn’t really what they should have learned. Until we provide real world examples of writing, many people will continue to learn, but they will learn the wrong way.