My son Finn is 6 and as pretty much every kid of that age he is wondering "What the heck is daddy doing all day". Therefore I was wondering for some time how I could teach him a little programming. I first considered Alice or to be more precise Alice Storytelling. Unfortunately it wasn't working on my computer. There are plenty of other systems designed for teaching kids programming, but the more I looked the more I doubted this would be the right approach.

These systems often work with some kind of visual interface, which allows to drag and drop commands. Thats great for kids that are used to a mouse a lot. While my son is certainly able to use a mouse, drag'n'drop is something taking full concentration for him. And when something drops in the wrong spot it is often quite difficult for him to figure out what happened.

At the same time I was reading Structure and Interpretation of Computer Programs which will teach you among other things Scheme. And I was amazed at the simplicity of the first program:

486

It will print 486. Not exacty a master piece of algorithm design, but you have to admit it is extremely easy. My son sure could do that. But I don't know Lisp or Scheme and I am a JVM guy. So I considered learning Clojure, until I remembered the Scala REPL. The Scala REPL is an interactive console based environment which will interpret you input as Scala code. So I fired it up typing scala in the command line and tried the program mentioned above:

[caption id="attachment_718" align="alignnone" width="606" caption="Scala REPL showing the simplest possible Scala programm: 486 (click for full size)"]Scala REPL showing the simplest possible Scala programm[/caption]

So I started teaching Scala to my son. The first programs where things like

2+3

After trying different expressions I introduced the concept of variables and dictated:

val lara = 3

Explaining that 'lara' has now the value 3

He immediately grasped the concept and tried the following

finn = 6

which resulted in

:8: error: not found: value finn
val synthvar$0 = finn
^
:5: error: not found: value finn
finn = 6
^

Since Finn can't read yet and doesn't speak English either there was no way he would understand the error message. So the only chance was comparing the command that worked and the command that doesn't until he figured out what was wrong.

I think that was the very first big lesson learned: Computers are extremely picky about what they are willing to understand.

After understanding that he missed the 'val' thingy at the beginning he declared a variable for himself, one for mom and one for dad, each filled with the respective age and added the ages until it was time to finish the first lesson of Scala programming.

So what are the lessons I learned from this?

  • visual interfaces can be a distraction
  • the simplest Scala program is by orders of magnitude easier then the simplest Java program. If you doubt that write down the simplest Java program and compare it to 486 and then add the steps of saving the file, compiling and running it to the equation.
  • If you don't have much to build on even the visual programming environments designed especially for kids are more difficult to master then the first steps in Scala


BTW: When we continued with the second lesson (repetition of what we learned + functions) Finn started to teach the stuff he learned to his younger sister (3 years old). I'll tell that anybody who tries to explain to me that he doesn't know anything worth telling others in a Java User Group.

Talks

Wan't to meet me in person to tell me how stupid I am? You can find me at the following events: