How to get a 9 year old interested in programming

Osx has a nifty command line speech synthesizer called “say”. It allows you to type some text and hear it “spoken” by the ubiquitous synthesized robotic voice. First, open the terminal and show him how it works by typing:
say "hello, my name is Robert"
Then show him that you can type different sentences and let him play with that until he gets the hang of it. Make sure to include enough potty humor to ensure sufficient hilarity:
say "Even though I am a computer, I sometimes talk about farts."
That should get his attention. You can also include question marks and nonsensical words for extra extra fun:
say "Are you some kind of flarpy nunckenbarf?"
The next step is to introduce the concept of variables:
friend="John"
say "$friend is a complete idiot"
friend="My hamburger"
say "$friend is a complete idiot"

By this time, tears of laughter should be streaming down his face, but don’t let it stop you. This is where the comedic potential really starts paying off with the introduction of the “for” loop.
for friend in "alfred" "max"
do
say "$friend is a fizzlebutt"
done

And then show him how to pause between the sentences
for friend in "alfred" "max"
do
say "$friend is a fizzlebutt"
sleep 1
done

Finally, once he finally peels himself off the floor and catches his breath, you apply the final coup-de-grace with the help of the “if” statement:
for friend in "alfred" "max" "frank" "dave"
do
if [ "$friend" != "max" ]
then
say "$friend is a total moron"
sleep 1
else
say "$friend has bad breath"
sleep 1
fi
done

After you share these intoxicatingly powerful instruments of distraction with your son, I suggest you steer clear of the technology teacher at the school.

Leave a Reply

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