[Haskell-cafe] Elevator pitch for functional programming
jim at sdf-eu.org
Tue Jan 20 05:07:05 EST 2009
Hi, I will be a TA on a comparative PL course and I'm looking for
small examples (ammunition) which motivate the use of Haskell and
functional programming generally. The course is for 1st year Software
Engineers, none of whom are likely to have used a functional
language. They will all have experience programming Java and a little
C++, with a few of them knowing Python, Ruby, PHP etc etc too.
If anyone has code snippets which are the equivalent of an elevator
pitch for FP, I would be very grateful to see them. What I want
are some small concrete examples of idioms which are natural and
powerful in Haskell but difficult or impossible in, say, Java.
So I can produce examples of some of the things that make FP powerful,
elegant, expressive etc: higher order functions, polymorphism,
composition (ask them to write (.) in Java :-)), partial application
and so on. I will point any interested souls to Hughes' great paper
. But I have little time and it might be hard to put across why
they would want to do these things in the first place. I was looking
for something that speaks directly to the kind of problems they face
in languages like Java...
Types are a good example because Java programmers generally already
appreciate the help they get from compiler messages etc, so you can
sell a more flexible, enhanced form of this. Purity might appeal to
anyone who has longed to be able to reason about nastily complex code
with a lot of shared state. Laziness, streams? Hard to do in Java (I
presume) but also quite hard to sell the need.
The existence of an O'Reilly book will help, especially one that can
be sampled online, so I'll point them at RWH for extended concrete
examples. They will need to be already sold before they will bother
with that though.
More information about the Haskell-Cafe