I’ve started teaching my son programming on the Raspberry Pi. The language? Haskell.
As an experiment, I thought I’d avoid the mainstream imperative languages: BASIC, C, C++ – stuff like that. Given he’s learning maths at school – counting, addition, subtraction, multiplication – all the fundamentals, I thought Haskell would be a good place to start: none of that imperative rubbish to cloud his learning – good, pure functions!
Here’s the lesson as it unfolds.
Step 1 – get the hang of the Haskell interpreter (hugs on the Raspberry Pi, as ghci isn’t yet available on the ARM architecture), and navigating around the keys
hugs > 2 + 2
hugs > 10+4
We did this for about an hour: I’d type a maths question in hugs – then before I pressed enter to evaluate the expression, he’d work out the answer and tell me. He loved typing in very large numbers, trying huge addition sums, and was impressed the computer could perform such huge calculations!
Step 2 – now the simplest of programs: counting to a hundred.
hugs > [1..100]
And the interpreter duly obliged with 1, 2, 3, .. , 100. Many variations on a theme here.
Step 3 – multiplication
hugs > 2* 2
And the next step is the one that caught my attention. My son tried this:
hugs > [2*2..2*5]
A functional sub-expression! Proper programming already.
Step 4 – Next theme: counting letters and words.
hugs > length “Twinkle twinkle little star”
hugs > length (words “Twinkle twinkle little star”)
I think functional languages are a superb fit for introductory programming. Haskell Pi = Excellent!