Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Tuesday February 17, 2009
09:54 AM

How To Not Teach Programming (Haskell)

[ #38501 ]

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?

THIS WAS MEANT TO BE TYPED AT A HASKELL PROMPT!!!

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

> [ x ↑ 2 | x ← [1..5]]
[1,4,9,16,25]

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 (edit: turns out that this is mentioned as in a single sentence after the Hugs compiler introduction, after the student discovers they can't type things in and I managed to miss this). 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
8

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 ?

Update: I forgot to mention that in the "Hugs" intro, there's this little gem:

> 7 ‘div‘ 2
3

If you don't know Haskell, what do you think you should type there? It's not explained in the introduction, the notation is not in the appendix and I eventually had to google for it. I had to play around with the HTML to replicate that as closely as I could.

Annoyingly, this is on page 12, introducing Hugs by showing various arithmetic expressions. The above is "integer division". Regular floating point division is not introduced until page 36 (and then as an afterthought) and coincidentally, that's also the page where the ‘div‘ syntax is finally explained.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • 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?

    I think I see your problem. Programming in Haskell is an academic text. It's written by a professor who is interested in approaching Haskell for students of mathematics. The target audience will understand the use of standard math symbols and their translations into ascii. That's one reason why it's so expensive yet so thin. It's not meant for "beginning programmers".

    For a more approachable introduction to Haskell, you should be looking at Real World Haskell. That book is geared towards a more typi

    • But why present code which the student can't type? (Even down to the Haskell interpreter prompt?) And the preface states that it's for computer science students at university level or anyone who just wants to learn Haskell. It's designed to be a tutorial and doesn't say that it's for math students.

      That being said, I need to check out "Real World Haskell". I've heard it's pretty good.

      • Don't take everything you see in books as the author's intent. My he screwed up, maybe an editor changed it, or something else. Who knows. Sure, the notation sucks, but why waste energy trying to figure out why? Note it and move on in life. :)

      • If it's written for an academic audience, it *might* be written with an assumption that most courses will have a lab set up with appropriate keyboards. (Or keyboard overlay and proper programming of one of the bucky keys.)

        Certainly, APL texts normally assumed access to an APL keyboard.

        • No, it's not for an academic audience. The back cover, the front page and the preface all make it clear that the book is for anyone who wants to learn Haskell.

    • Haskell as a first language is not really a good idea

      The University of Melbourne used to teach Haskell as a first language to all the computer science students (they may still, but I'm not there anymore). This worked superbly well. It worked particularly well as a leveller. Those students who'd come into the computer science degree already knowing some other language were neither advantaged by their previous experience or disadvantaged by the bad habits they'd picked up. It gave a nice, sensible int

      • They are starting to teach Haskell as a first language at the University of Edinburgh as well. However, as someone with a background in programming and the Humanities, I have to say that all the Haskell tutorials for "beginners" that I have seen online and off have all failed miseribly. After the first few examples, they tend to fly off into the realms of higher mathematics when really, all I want to do is manipulate texts.

        I have started teaching Perl to the Humanities students that I come in contact with