Teaching programming to a nine-year-old

My younger daughter is nine. After watching me sit with a laptop all term preparing material using Scheme, she wanted to know something about it. She is self-taught on the application side of computing (browsers, paint programs, word processing) but knows nothing of computation itself. So I opened up a DrScheme Interactions window. "You add like this," I said, typing in (+ 3 4). No problem. "Try some other operations, some bigger numbers." It looks like a calculator without a ten-digit limit.

I wrote out some arithmetic expressions for her to convert to Scheme. She had difficulty with them, but not with Scheme: I had forgotten how much algebraic notation is taught later. She didn't understand concatenation for multiplication, / for division, or putting two expressions one above the other with a horizontal line in between. Once I explained those, she converted them into Scheme expressions very quickly.

Next lesson. I showed her how to define constants. Her age, her sister's age. Subtracted the younger from the older. Defined my age. Subtracted her age from mine. "What if you want to do this for a lot of people's ages, find out how much older than you they are? You can define a function." Typed in (define (older-than-zuki age) ...). We used it in the Interactions window. "If you have a square that's 4 inches on a side, how many square inches does it contain?"

"Sixteen," she said.

"How did you get that?"

"Multiplied 4 by 4."

"Okay, write a function that consumes a number and produces its square." She wrote it, without hesitation.

"What is the sum of the squares of 3 and 4?"

"Twenty-five," she said, after blinking for a bit (she's not good with rote calculation, just like me).

"Okay, write a function which consumes two numbers and produces the sum of the squares." She wrote:

(define (sum-of-squares number)
  (+ (square number) (square number)))
I'd been prepared to see (* number number) again, but she didn't do that. "Try it." She typed (sum-of-squares 3 4) into the Interactions window, and DrScheme gently complained that it expected one argument but got two. Without hesitation, she put in a second "number", so it read
(define (sum-of-squares number number)
  (+ (square number) (square number)))
She clicked Run, and DrScheme gently complained that an argument name was used more than once. "Oh," she said, "I have to call it -" and she made the second argument "number2", and fixed the body. Worked.

Then we did Fahrenheit->Celsius, no problems. "Can you do Celsius to Fahrenheit?" She changed the operations (subtract becomes add, etc) but didn't change the ordering in the code (even though she got them in the right order verbally), so when she tried it in the Interactions window, it gave the wrong answer. "There's a Stepper, which simplifies one step at a time if you put the expression up in the Definitions window. Try it."

She stepped a bit, said, "It's doing the wrong thing first," switched the operations around, tried it, and it worked.

Now that is intuitive. A language that a nine-year-old can start to grasp right away because it connects to past experience and doesn't require notions of time and boxes containing numbers that change, and software (thanks, PLT!) that gives her the feedback she needs to diagnose and fix her errors, instead of arcane gibberish.

This weekend we'll try Kathi Fisler's fabric exercises or Stephen Bloch's image manipulations, and then I will start in on word problems and posns. I taught my fall students Scheme using algebra as a tool; I'll teach my daughter algebra using Scheme as a tool. Why doesn't everyone do it this way?

Dr. Prabhakar Ragde, University of Waterloo


Last modified:
Stephen Bloch / sbloch@adelphi.edu