

[Ask HN] Good book about functional programming? - steiger

Hello all.<p>What would you recommend me to read if I want to dive deep into the functional programming paradigm? There's plenty of this kind of material for Object Oriented programming (of course, given the hype.), but i dunno about FP.
======
dasil003
Maybe it's too obvious but someone's got to mention Structure and
Interpretation of Computer Programs (aka SICP). It's not strictly about
functional programming, but it starts with functional programming and then
discusses the implications of adding mutable state. I think it's a good idea
to get that under your belt before diving into Haskell where it's already
taken as a foregone conclusion that the negatives of mutable state outweigh
the benefits.

<http://mitpress.mit.edu/sicp/>

------
mbrubeck
They're both designed to teach specific languages, but I found both _Real
World Haskell_ and _Programming Erlang_ conveyed a lot about practical
functional programming. You can read RWH for free online (but it seems to be
down as I type this): <http://book.realworldhaskell.org/>

~~~
10ren
I also found Armstrong's Erlang book excellent for an intro to functional
programming (but it's not particularly advanced). I got the pdf-only version,
which is a bit cheaper.

The obvious recommendation for fp (functional programming) on HN is SICP
(Structure and Interpretation of Computer Programs). The full text is free
online <http://mitpress.mit.edu/sicp/>

_Everyone_ raves about SICP, from top to bottom of the fp world.

However, some objections: 1. it purports to be an introduction to programming,
but it assumes a lot of background knowledge (so that's fine if you have the
background, but the inconsistency irritates my inner pedant). 2. the authors
don't use it themselves anymore in their programming course (they switched to
python, for variously debated reasons).

~~~
ananthrk
_it assumes a lot of background knowledge_

What kind of background knowledge is required?

~~~
10ren
Some examples from chapter one: the concept of local variables (used but not
explained); the conventional meaning of recursion (when they argue that TCO
only applies to iteration despite having the form of recursion); and (and
IIRC) approaches to mathematical proofs that it argues against (there are also
some mathematical examples, like implementing Newtons method, but I think
that's OK).

There's also a bit of imagery that only makes sense if you already know what
it means. As someone who's taught at Uni, I think that's pretty poor in an
"introductory textbook". However, the simple truth is that it isn't an
introductory textbook at all, but something more advanced and arcane.

~~~
ananthrk
Thanks for the response. So, what would be a good book _before_ SICP?

~~~
10ren
Are you asking about fp, or programming books in general?

One approach I took was to go to the (University) library, and find the
section on the programming topic of interest. Then grab a few books, and read
a paragraph at random. Then borrow (or read there) the one that appeals to you
- the writing style that makes sense to you, that addresses the issues that
come to you as you read, that communicates to _you_. You can do the same at
Borders, but the books are more vocational and less textbooky.

If some particular part is unclear, you can compare it with other books - you
now have a resource.

Every book has something to offer. The biggest factor is what you put into it.
Therefore, it's more important to pick a book that you like rather than the
"best" one. Otherwise, you can get into a kind of McCarthyism where there are
good books and bad books, instead of each book having strengths and
weaknesses.

To put this in perspective, I personally really liked "Java in a Nutshell",
because Flanagan's writing is brilliant. It's very succinct, yet covers all
the cases, has a joie de vivre about it, and yet is so transparent it's easy
to not notice it (Douglas Adam's prose also has this quality). Revealingly,
Flanagan loves writing; and is very well read himself. Most writers of
programming books are not. Now, to me, being well-written is very pleasing;
but I can imagine it not mattering at all to the next programmer.

------
jlouis
Larry C. Paulson - "ML for the working programmer" will have you thinking for
years to come. It is meant for people who do know a programming language, but
none of those an FP-lang.

It covers Standard ML, but you will find that the ideas of FP are easy to move
around from language to language.

------
jonjacky
Bird and Wadler, Introduction to Functional Programming is a classic. They
have a more recent book, Introduction to Functional Programming in Haskell,
which I haven't seen.

