Thursday, December 27, 2012

Kids Code Camp, Austin, Texas, April 22, 2012

Teaching programming -- even to adults, but especially to kids -- presents you with a dilemma, all the more acute when you only have 1 hour to interest your students in the subject. You can take a practical approach: let's create a toy program that does something you like: move, bounce, play sounds. Or you can take a more-or-less exploratory approach: write some simple code, tweak various parameters in the program, and see how the computer responds. It is like having a "stick" -- a programming language -- to "poke" the computer with. What does it do when you issue this, that, and the third command to it, even if those commands don't add up to any eventual goal? I, personally, think the first approach would interest more people (especially children) than the second one. But the first one is harder to achieve. It's not easy to design a course where students would write a program simple enough for beginner to accomplish in 1 hour, but meaningful or entertaining enough to make students want to do more of this.

So it's not surprising that the Kids Code Camp -- a day long series of programming classes for kids -- took the second route.

For the first session, Ron Evans (@deadprogram) from Hybrid Group taught kids to write a few basic Ruby programs with KidsRuby. It's a programming environment that lets you easily write a simple program and run it. And by “easy” I mean it eliminates the overhead of creating and saving files, wondering what directory to save them to, how to invoke the compiler, what libraries to include, etc. It lets you run just the "meat" of the program. Not only you don't have to open a file, you don’t even give have to your program a name. Just type the program in the left pane of the KidsRuby window, and press the button "Run". The output will appear in the right pane.

Or... not.

Ron Evans gives out candy to kids at the Kids Code Camp who answered the questions right.
Ron Evans gives out candy to the kids who answer questions right. Eventually he gave candy to all the kids.

The "little" problem with KidsRuby is that if you make a typo -- for example, don't close a string with a double quote (") -- it doesn't print an error message. Your program just won't run. Needless to say, for beginning programmers this makes it one of the, shall we say, least useful programming tools. If your code won't point out your syntax errors, how are you supposed to know what's wrong with it? You’ll probably lose your interest. The only way a kid could sustain interest in this is if there was an adult nearby with knowledge of Ruby, or basic programming -- or if the kid was a precocious genius, armed with programming books and hell-bent to figure out what's wrong.

Turtle.start do
background yellow
forward 30
turnright 90
forward 50
turnright 90
forward 50
turnright 90
forward 50
end

-- draws a square.

Turtle.start do
background yellow
pencolor blue
turnright 45
forward 50
turnright 90
forward 50
turnright 90
forward 50
turnright 90
forward 50
end

-- draws a diamond.

This brings me to another topic. Hell-bent precocious geniuses will eventually figure programming out on their own, but what exactly is the audience to which one should teach? The traditional audience -- kids who are interested in tinkering of any kind, in pressing buttons and typing cryptic commands just to see what they do? Those were the typical kids who studied programming. Or do we also want to teach kids who, like me, would have found such a thing mostly pointless? If, however, someone had shown me what you can make with it -- a finished object, something with a purpose, even if only a toy -- I would have been much more interested. It was via this route that I eventually discovered my interest in programming as an adult.

As I noted above, the purpose-oriented approach is much harder to teach. However, some programming environments lend themselves more easily to this approach than others. One of the sessions at the Kids’ Code Camp explored a graphical programming environment called Turtle. Its commands specify how far a colored dot has to go and in what direction, or how many degrees to turn and in what direction, in order to draw a figure you want. (Sample Turtle code is shown in the sidebar.) So you can fairly quickly learn how to write a program to draw a geometric shape pixel by pixel. I also liked how the presenter explained pixels to kids: put your nose to the screen and see if you see any dots - those are pixels.

Here's the code of What I Did on my Summer Vacation program:

holiday = ask "Which holiday?"
familymember = ask "Family member?"
activity = ask "Activity?"
smallproblem = ask "A small problem?"
puts "It was just " + holiday " "."
puts "I was with my " + familymember + "."
puts "I also went " + activity + "."
puts smallproblem + " but it was OK."
puts "It was a good " + holiday + "."

Writing a program to draw a complete geometric shape may be more than you could learn in 1 hour with Scratch, another children's programming environment that was introduced at Kids’ Code Camp. Scratch doesn't let you manipulate individual pixels like Turtle does. In this environment everything is done graphically -- programming constructs such as loops and variables are colorful interlocking widgets you snap together to “write” a program. It's best suited for creating animations involving a vast choice of cute avatars. It is very handy for explaining such concepts as loops, since you can make the avatar repeat animated motions endlessly. But programming is knowing not just how to create a loop, but how to combine it with other code concepts to achieve what you want. And to do that in Scratch, you'd have to spend more than 1 hour -- especially if you are a kid, especially if you haven't yet learned coordinate system or negative numbers. You have know that in order to tell the avatar where to move. And to get your avatar to move to a precise location, you can only do that with trial and error, by plugging in different numbers and seeing where it goes. Not exactly a riveting activity...

At one point, though, the curriculum of Kids’ Code Camp showed a hint of purposefulness. While teaching Ruby, Ron Evans introduced a "hack your homework" program. It was a ~ 10-line KidsRuby program that asked you "where, when, who, what" types of questions, and plugged your answers into a cookie-cutter essay: "Last summer I went fishing with my cousin", etc. Then it spat out a finished text that probably wasn’t worse than an average student’s homework. :-)

No comments: