The Pythagorean Theorem was once a profound and dimly-understood secret. Today we teach it to children. I'd say that's a pretty good test of whether we fully understand something. What parts of computer science can really we teach to kids today? Remember that computer science has nothing to do with computers as such, any more than geometry is about surveying land.

A story about computer science

and other improbable things.



Alan Kay has a classic talk about different modes of thinking and an experiment he did with young people of different ages. Imagine a robot that can do four things: move forward some distance, move backward, rotate some number of degrees, and make a mark on the floor. The goal is to write a program that tells the robot to draw a circle.

Before I tell you what happened, do take a minute and try it yourself. It's a pretty problem.

Precocious teenagers are stuffed full of facts about circles and curves, πr2 and calculus and all of that. More to the point, they have been trained in school to think abstractly and to leave aside visual or visceral thinking. Given this robot exercise they would spend 45 minutes on the blackboard writing equations and looking up things in books and scratching their heads before giving up.

Then Kay found some 10-year-olds and gave them the same problem. A 10-year-old doesn't know much about equations. She's a visual thinker. She doesn't know much about circles either, but she does know that a circle is defined as all points that are the same distance from the center. After about ten minutes of thinking and doodling she writes the program this way:

Start at center. Move forward N inches. Make a mark. Move backward N inches. Rotate 1 degree. GOTO 1

That is a significant result. Ten-year-olds beat the pants off teenagers by using an officially discouraged mode of thinking. Not satisfied with that, crazy old Kay invited in a bunch of five-year-olds. You don't let little kids play with chalk if you want to get any work done, so for them he turned it into a game:

"Ok kids, you are robots. Say Beep beep beep! Good, now cover your eyes, and I want you to walk in a circle."

The kids would cover their eyes and cock their heads for a few seconds, thinking about how to walk in a circle while blind. Then they did it. They walked forward just a little, then turned a little, then walked forward again, and so on until their inner ear told them they'd done a full circuit. Not only did these children solve the problem immediately using visceral thinking, their solution was hundreds of times more efficient. Somehow they were intuiting differential equations.

What can I teach a child about computer science? It may be better first to ask what a child can teach me. I don't mean that in the Romantic sense of noble savagery or the wisdom of innocence. Computer science is the study of process: how to do things, how to figure out things, and especially how to figure out how to do things. We have to investigate everything that seems to work, wherever we find it. Visually and viscerally-centered thinking seem like rich veins to explore.

One of Alan Kay's favorite sayings is that having the right point of view is worth 80 IQ points. No matter how clever you are, if you're trying to figure out cube roots on an abacus you are not going to get very far. The right point of view can make the difference between an elegant solution and a pile of steampunk.

Fortunately it cuts both ways. If something you are working on seems to be inelegant, too full of random details and not enough clear principles, that's a sign you might be approaching it with the wrong point of view. Being able to recognize that state and pull yourself out of it is an invaluable skill. Both the hidebound and the feckless are crippled because they can't choose where their minds go next. An interesting, perhaps defining, characteristic of highly creative people is their ability to shift their point of view at will.

Often, especially when learning some large new system, programmers get stuck on something that looks like a bug and ask someone for help. Halfway through explaining their problem they realize where they had gone wrong. Never mind, never mind, it's not a bug, I'm an idiot. At a company I used to work for we had a stuffed bear called the bugbear. Before you could bug anyone else about your bug, you had explain it to the bugbear. Just thinking to yourself doesn't always work; there is something about vocalizing your mini-mental crisis to another being that engages the brain.

So, back to the question: what can we teach a child about computer science? It isn't an abstract set of laws you learn because it's good for you. Computer science is the study of how to do things --anything-- faster and better. It's more than that, of course. But the practical side is ultimately the source and purpose of all this commotion. (Right?)

Two people painting a house is task parallelism. Since they are doing the same job they each need a bucket and brush. Otherwise they'll waste too much time walking back and forth. They also need to make sure that they paint all of the house and don't paint parts that have already been painted. An easy way to coordinate is to start at opposite ends of the house. Even if one person paints faster than the other, they will eventually meet and be done.

Washing dishes is a little different. There is only one sink so two people can't wash at once. But one person can wash and another can dry. They form a short "pipeline" that dishes flow through one their way to be cleaned. Let's say it takes 30 seconds to wash a dish and 30 seconds to dry. 50 dishes would take 50 minutes for one person. For two people it would take 25 minutes and 30 seconds. 50 / 2 is 25, not 25.5. The extra half-minute comes from how pipelines work: the dryer can't start until the first dish has been washed.

As pipelines get longer and more complex, managing delays becomes very important. Everyone has been to or seen videos of factories with their long conveyor belts, robots and people. If one section stops the whole line stops. Even tricker is managing stages that have different speeds. If you can make the candy faster than I can put them into boxes, then candy will build up behind me.

To wash your clothes right you should separate the colors. A really fun way is to sit in the center of the room and toss darks, lights, and colors into different corners. A lot of high-tech companies gauge engineering candidates by their ability to solve the so-called Dutch National Flag problem. A lot of job candidates fail to figure out the trick, and perhaps fail the interview. I don't think that's a problem with the candidates or the basic idea of whiteboard interviews. I think it's a problem that we think DNP is a hard problem, when it is literally child's play.

If you've ever seen an old war movie you've heard the characters reading numbers over the radio: One niner five alpha bravo ---repeat--- one niner five alpha bravo!. Numbers have to be clear so they say "niner" because "nine" might be mistaken for "five". They use words for letters so no one confuses B with D, P or E. They also repeat important information as an extra safety. It takes longer to communicate this way but getting it right is more important than efficiency. Computers communicate this way too. In fact the theory behind the tradeoff between efficiency and reliability, called Shannon's information theory, is one of the ideas that made modern communications possible. One of the neat things about coding theory is that you can control exactly how efficient or reliable you want something to be.

A book of How

There are a thousand of these little explanations one could come up with. Doubtless you've invented some of your own when learning a new thing or teaching it to someone else. Children do it all of the time, and we do it all of the time with children. But as far as I know they are not collected or connected with more general concepts. It's almost as though people are embarrassed to use such devices as a regular thing.

If you want to know What something is you look it up in the dictionary or encyclopedia. If you want to know Where something is you look at an atlas. When is covered by history books. Why and Who are kind of scattered about, but a lot of the answers are in history books and encyclopedias. All of these tools: encyclopedias, atlases, histories, were invented. They were invented and compiled one halting step at a time in response to need.

Computer science is, possibly, an attempt to write a book of How. We don't really know what it will look like, kids, but you're invited to help us find out.