[Haskell-cafe] Why functional programming matters

Evan Laforge qdunkan at gmail.com
Thu Jan 24 18:04:43 EST 2008

> This takes an iterator over some collection of Foos and finds the one
> with the highest value of updateTime.  9 lines of code, or 12 with the
> closing curly brackets.
> In Haskell this is so short and obvious you probably wouldn't bother
> declaring it as a function, but if you did, here it is:
>    -- Find the Foo that was most recently updated.
>    latestUpdate :: [Foo] -> Foo
>    latestUpdate foos = maximumBy (comparing updateTime) foos
> Of course you could always write it in point-free format, but I think
> that would be over-egging things.

Java's just wordy like that.  In python you'd say max(foos, key=lambda
x: x.update_time).  Python / perl / ruby / smalltalk have had first
class functions forever, so those are basically already in the
mainstream.  They may impress a java or C programmer who's never seen
a dynamic language.  It might reassure a python programmer that static
typing doesn't preclude using closures and doesn't mean c++ or java
style huge long declarations.

So you probably need some other examples to convince python
programmers that their language didn't just cherry pick all the great
ideas and that there are none left.

> Well... ghc still has a single-threaded garbage collector, so all the
> "par" threads must stop for garbage collection.  So scaling to the
> level of a cluster would be significantly sub-linear.

A real time incremental gc would be really cool.  Some people claim
they exist, but which languages have one?

More information about the Haskell-Cafe mailing list