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:
nbsp;nbsp;(⨁)nbsp; = λx → (λy → x ⨁ y)
nbsp;nbsp;(x⨁) = λy → x ⨁ y
nbsp;nbsp;(⨁y) = λx → x ⨁ y
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.
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 typical O'Reilly audience -- practitioners and programmers. It's not an introduction to programming (Haskell as a first language is not really a good idea), and expects the reader to have a background in some other language before beginning.
Re:Wrong Audience
Ovid on 2009-02-17T16:43:53
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.
Re:Wrong Audience
brian_d_foy on 2009-02-17T17:49:56
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.
:) Re:Wrong Audience
autarch on 2009-02-17T18:35:31
Well, it's useful information for someone considering purchasing the book.
Re:Wrong Audience
brian_d_foy on 2009-02-17T21:12:20
The "what" portion is useful; the "why" portion not so much.
Re:Wrong Audience
kag on 2009-02-17T19:34:42
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.
Re:Wrong Audience
Ovid on 2009-02-17T21:16:57
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.
Re:Wrong Audience
jarich on 2009-02-17T22:13:41
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 introduction into useful things like commenting your code, using meaningful variable names, indenting code to make it readable, breaking bigger problems up into smaller ones, thinking about types etc.
As someone who tutored those first year students, and ran the lab classes; but who also had experience running lab classes for students going straight into C; I think Haskell made a fantastic first language. I'd happily recommend it to a friend who wanted to learn how to program.
Fortunately for our students, we worked from the lecturer's notes and a mini-book they'd written (originally for Miranda and then converted to Haskell). So the students didn't have to do any weird symbol conversion when it came to typing stuff in.
Re:Wrong Audience
cyocum on 2009-02-17T22:33:41
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 (much to the chagrin of the Informatics Department) but Perl does what we want: it manipulates texts easily.