Teaching my 11-Year-Old Daughter to Program, Part 2

In my last post I said I am starting to teach Ruby to my daughter Rosey. So today after getting back home from watching Tangled in 3D we got started. She had done the first reading assignment last night (Preface, Intro, and Chapter 1 of Learn to Program). Our next step was to sit down and follow the instructions in Chapter 1, which was about installing and setting up the environment.

First I had to set some ground rules. Well, one ground rule:

Let’s stay on topic.

Kids always want to tell you random things. Unless they’re teenagers, of course, in which case I’m told they close off in their room for about four years. So I gave her a piece of paper and a pencil. If she thought of anything unrelated to programming that she was dying to tell me, she could write a reminder to herself on the paper and tell me later. I think it helped. At one point she was juuuuuuuuuuuuust about to tell me something but she caught herself and just wrote it down. I think having this release valve helped get the idea out of their head so she wouldn’t be distracted and could concentrate.

So, down to work. We installed Ruby on her laptop with the Ruby One-Click Installer. Yes, it’s her laptop even though we have three kids. Each kid has their own laptop. Refurbished corporate PCs are pretty cheap. And we installed Notepad++ too, since I love it.

Rosey had fun playing with the echo command on the command line, echoing everything I said. Having a computer do this is only slightly less annoying than having a person do it. Then she did this at the prompt:

C:>:-)

And to our surprise, there was no error message. It just came back with another C: prompt. I guess that’s because in the Windows batch language a line that starts with a colon is a label—and you can put anything you want after it. Fun.

We finished Chapter 1 in a hurry and I was worried it wasn’t the best first day. Fortunately, she said yes when I asked if we could just do the first two paragraphs of Chapter 2 since I saw that’s where the instant gratification begins. She was hooked after this worked:


puts 1 + 2 # => 3

She experimented with some other math. I told her about * and / for times and divided by, and she did:


puts 300 / 8

but was surprised when the program printed 37 instead of 37.5. At that point I became pretty impressed with the order in which the book introduces new concepts, because I had read ahead and knew that the next page describes integers vs. floats, and goes on to explain why integer math always returns an integer. We read through it, typed in the examples, and were having fun. The book impressed me with its clairvoyance again when Rosey got tired of typing the spaces between the mathematical operators and asked if they are really needed. I showed her the next paragraph, which said “the spaces in the program are not important; they just make the code easier to read.”

Rosey also tried one of her favorite phrases:


puts I like pie

but she got an error message because she doesn’t know yet that strings have to be quoted. (The command-line echo command didn’t need them.) I decided not to bother explaining that for now, since the next chapter goes into it.

At one point the book said, “Don’t type commas into your numbers” because it just confuses Ruby. But I taught her a little-known Ruby trick, using underscores where you would have used commas. She’s learning ancient ninja secrets.


puts 1_000_000

I thought the exercises at the end of Chapter 2 would be hard. They ask the reader to solve problems like “How many hours are in a year?” and “How many seconds old are you?” It turned out they were a piece of cake. She raced through them, stopping only a few times to figure out whether to divide or multiply.

Next up: Rosey’s next reading assignment is Chapter 3, “Letters,” which talks about strings. Christmas vacation is over and school starts up tomorrow, so her homework will take precedence. But hopefully we’ll be able to keep the pace going and not lose steam.

So far so good!

Leave a Reply

Your email address will not be published. Required fields are marked *

Feel free to use <a>, <b>, <i>, <strong>, <em>, <strike>, <code>.

Code blocks:
[code language="ruby/javascript/html/css/sass/bash"]
[/code]