23 February 2012

Computer Science is "How"

Carlos Bueno | Corrupting the Youth

On the one hand I think this a really good piece, the thesis of which I agree with entirely. Computer Science is about how to do things, and understanding it is a very general skill which helps explain the world.

On the other hand, I think this is a bad example:
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:
  1. Start at center.
  2. Move forward N inches.
  3. Make a mark.
  4. Move backward N inches.
  5. Rotate 1 degree.
  6. 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.
Actually the 10-year old is very clever. I think that's a great example. The example with the 5-year olds is bad though.

I think one of the very valuable things about learning computer science and learning to program is figuring out how to construct a solution to a problem in an explicit enough way that you can explain it to someone else. In particular, you need to explain it to someone who is pathologically literal-minded — ie the computer.

What the 5-year olds are doing is entirely unlike that. An answer to "how to do get a robot to move in a circle?" can not be "close your eyes and walk around in a circle." Their "visceral," "intuitive" solution is great, but it's the opposite of what we're looking for. It's not the steps required to solve the problem, it's simply a solution to this particular instance of the problem, performed once, that they understand but which can not be expressed to anyone else, particularly someone inhuman.

PS The hack solution for this problem that I like goes as follows:
  1. Tie a string of length N to the robot.
  2. Tie the other end to a post at center of the circle.
  3. Have the robot go forward 2πr inches.
  4. Stop

PPS I could have mentioned this kind of thing in the previous post regarding what political candidates could do to impress me instead of wearing hard-hats while touring industrial plants and pretending they enjoy bowling.

If they can solve this sort of algorithmic problem then I'll respect them a little more. Nothing terribly complex. I'm thinking about questions easier than the "Dutch Flag Problem" which Buenos mentions, and not as explicitly computational. Good examples would be the non-automotive, mathematical questions that are asked on Car Talk's "Puzzler" segment like "The Coney Island Crab Cake Company" or "Stone Temple Farmers." If you can reason out answers to those, or at least take a running start at them, you're more likely to have my vote. Plus getting candidates to answer these questions — live! — would dissuade people from confusing oratorical skill with intelligence.

PPPS From Buenos' article:
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.
(1) I'd never thought about the NATO phonetic alphabet as an Information Theory application before, but now it's so obvious.

(2) Isn't nine pronounced "niner" to distinguish it from the German "nein" not "five"?


  1. Regarding your solution to the circling robot: make sure the string is looped around your central peg or you'll wind up in a helix.

    My thought was: move forward 1 inch, turn right 1 degree. I haven't worked out whether it would actually work or not.

    As far as niner--why would someone be repeating the German word for "no" along with a bunch of numbers? Also, with a staticky signal, "nine" might sound more like "five" than normal, and certainly those two are more similar than any of the other single digit words.

  2. Good point with the helix. I'd need a nice loose hitch around the central peg.

    I'm pretty sure "forward 1, right 1" doesn't work. It gets you back to where you started eventually, but what's the radius of the resulting figure? Whatever you do needs to be a function of the desired radius.

    I'm not sure exactly why you would say "no" in the middle of some numbers, but I can see it being possible since both numbers and "no" are both going to be very common things said. Maybe you German-speaking Luxembourgian ally says on the radio "This is flight delta one three ...nine... four." Does he mean "D1394" or "D13...no...4"? Okay, that's a lame example, but do you really want to stop in the middle of combat operations to clarify things like this?

    I know people with more military experience than me (i.e. greater than zero experience) read here from time to time. Perhaps they can clarify the reasoning behind "niner."