Ovid (publius_ovidius) wrote,

How Not to Teach Programming

Note: heavy use of HTML unicode character codes here. If some of the following is garbled, I trust you'll understand.

So I have the book Programming in Haskell. So far the book seems to be fairly straightforward, except for one little hitch. Here's the start of the second paragraph of the inside front cover:

This introduction is ideal for beginners: it requires no previous programming experience and all concepts are explained from first principles with the aid of carefully chosen examples. Each chapter contains a series of exercises ...

Exercises? For beginners? Well, do beginners to programming want to read about programming or to program? Almost everyone I've ever met wants to dive in and make things which print "Hello, World" and move on from there. We want to program, so a Haskell book for beginners with exercises sounds perfect for me.

So since this is for beginners, some might be surprised to see this:

  (⨁)  = λx → (λyxy)
  (x⨁) = λyxy
  (⨁y) = λxxy

But the text builds up to this at that point and the above is understandable (the author's really good about this), but still, it's the sort of thing which makes many a student put down a book. However, that was merely a formalized definition of something and wasn't too bad. Here's what's too bad:

  > [ x ↑ 2 | x ← [1..5]]

The above is a list comprehension in Haskell. It will generate a list of the square of the numbers one through five. Note that this is not the mathematical notation of a comprehension. Prior to the above horror, the author clearly gives the mathematical notation:

  { x² | x ∈ {1..5} }

So the author can't use the excuse that he was showing mathematical notation. However, the keen observer might notice a small difference between them:

  > [ x ↑ 2 | x ← [1..5]]
  { x² | x ∈ {1..5} }

Hmm, what's that leading angle bracket on the Haskell version?


Yes, that's right. Here's that full snippet from the book:

  > [ x ↑ 2 | x ← [1..5]]

The author gives code that the beginning student cannot type in! There is a "symbol table" in Appendix B which has a mapping of those funky characters to what the poor student should type in, but it's not even mentioned at the beginning. New to programming? You get to guess this. I'm not making this up. Even the book's intro to the Hugs compiler has this:

  > 2 ↑ 3

What on earth could convince someone writing a programming book for beginning programmers that having them type in examples they can't type in would be a good idea? The rest of the book seems fine, but this is just, wow. I'm at a loss for words. And I just gave you the easy ones to figure out. You think the beginner is going to know to type \ for λ or /= for ?

Tags: programming
  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded