I found Chris Done’s
A philosophical difference between Haskell and Lisp
and my response ended up blog-post length so I decided to reproduce it here.
Chris opens with:
One difference in philosophy of Lisp (e.g. Common Lisp, Emacs Lisp) and
Haskell is that the latter makes liberal use of many tiny functions that do
one single task. This is known as composability, or the UNIX philosophy. In
Lisp a procedure tends to accept many options which configure its behaviour.
This is known as monolithism, or to make procedures like a kitchen-sink, or
a Swiss-army knife.
Now, I don’t know Common Lisp, and not much Emacs Lisp, but his first example
does not hold for Clojure. I don’t recognise it at all. For example, a
straight-forward beginner’s implementation of this function:
take all elements from the list–except the first three–that satisfy
predicate p, and take only the first five of those
Would probably look like this:
However, this would probably be more idiomatic to rewrite it using the
macro. This has the benefit that the wording in the spec matches the code
I’m not sure what’s going on with the second problem:
get all elements greater than 5, then just the even ones of that set.
It looks to me like neither his lisp nor his Haskell solution works, as they
both get only the even numbers below 5. So, I’ll show my solution to both
the stated problem and my implementation of his examples in Clojure. The
stated problem first:
The problem that his code examples solve I would do like this:
Ok, that was cheeky, so let’s show it with code too:
0 is not desired:
Range has a
step option too, but I’d hardly call it a kitchen sink function:
So we could solve this like this too:
Alternatively, if you really want to use 2 functions, we could also emulate
his Haskell solution:
As others in the Lobsters thread commented, Scheme also favours small
composable functions. Perhaps all this shows is the problem of trying to
divine a philosophical difference between a single language and family of
languages twice its age with over 25 dialects listed on Wikipedia.