[plt-scheme] Can you study HTDP to satisfy the goal to learn Functional Programming?

From: Mark Engelberg (mark.engelberg at gmail.com)
Date: Wed Sep 10 01:03:28 EDT 2008

On Tue, Sep 9, 2008 at 9:13 PM, Grant Rettke <grettke at acm.org> wrote:
>> Unfortunately, I can't recommend just one book for this purpose.  Over
>> the years, I've read a large number of books written in a variety of
>> languages, and most books have one or two large programs to study, so
>> for me it's been more of a cumulative process.
>
> What are some of your favorites?

My memory is pretty hazy, which is why I avoided being specific the
first time around :).  In part, that's because I get most of these
books through my library system, and I don't really remember any more
which programs I saw where.

Since you already know Scheme, you'll probably really enjoy the
extended examples in Siebel's Practical Common Lisp (free version
available on-line).  As for other Scheme examples, I think SICP had
some good extended examples (wasn't there an interesting FP
circuit-simulator example in that book?), but I'm not certain.

Have you read Okasaki's book?  Understanding how to write purely
functional data structures such as queues, and lists with reasonably
efficient random access is an eye-opening experience.  It helped me to
understand both the benefits and the challenges of writing in a pure
FP style.

Have you seen Graham Hutton's "Countdown Problem" example in
"Programming in Haskell"?

I think "The Haskell School of Expression" had a nice example of how
to write a DSL to represent and manipulate music algorithmically in a
purely functional style.

The old Clean manual had some good case studies, but I think they were
removed from the website because the code was incompatible with the
latest version of Clean.  Ditto with the Dylan book.  Maybe it would
be possible to dig up old copies of those somewhere?

How about the implementation of a two-player game complete with AI in
the O'Caml book?
http://caml.inria.fr/pub/docs/oreilly-book/html/index.html

>
>> Of the books I've read
>> most recently, the new Erlang book comes to mind as having a couple
>> good extended examples of FP in action.
>
> What were some of your take-aways from this book?
>

For me, it was really enjoyable to read extended code by the designer
of the Erlang language, and see how he would design and organize a
slightly long-ish program (I think one of the longer examples involved
 a chat program).

I like reading code like that and thinking about how I would do it.
Some of the things seem really elegant, and sometimes I just find
myself thinking, "You know, that seems weak; other languages do that
better."  Erlang definitely showcases some instances where FP shines,
because the guarantee of immutability makes it much easier to
understand some of the parallel code.  On the other hand, I think that
certain useful data structures would be a total pain to code in
Erlang.  So, it also makes me appreciate certain features from
"impure" languages.

Anyway, maybe others can chime in here.  What's the most instructive,
readable, clearly-documented, non-trivial FP program you've seen?

--Mark


Posted on the users mailing list.