[Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language.

Shelby Moore shelby at coolpage.com
Sat Oct 31 16:34:27 EDT 2009

I found the post at the following link to be the most useful in explaining
declarative versus imperative:


Here follows what I want to add to the discussion:

John Dorsey wrote:
>> Well, try this: Go ask a random person how you add up a list of numbers.
>> Most of them will say something about adding the first two together,
>> adding the third to that total, and so forth. In other words, the step
>> by step instructions.
> You word the (hypothetical) question with a bias toward imperative
> thinking.  You're asking "How do you do this action?"

> Why isn't the question "What is the sum of a list of numbers?",
> which is biased toward the declarative?

Instead ask "How do you add some numbers?"

Then you will more likely get the answer, "add them together".

The disconnect is that most people do not think in terms of details, so if
you ask them to think in terms of how to declare "the order of the
operation over the set in minimized semantics", you will push them into an
area which they are not specialized.  I have read the claim that Haskell
tends to attract some of the most talented programmers, because it
resonates with the mindset of people who like to generalize details into
minimum rulesets.

The most accurate question should be, "How do you add some numbers with
minimized instructions?", because it forces them to realize they must
order the set.

An answer might be, "Zero if empty, else order the set, sum the first
number with the sum of remainder of the set. Repeat for the sum of

The real leap for me (not using my college math recently), and I am sure
for most imperative programmers and people in general, is go from the
recursive declaration above, to the notion that the declaration __IS__ the
sum and does not just _return_ or output the sum.  That notion becomes
important when the declaration is not a single number result, instead a
set.  That is important because there is no way to _return_ an infinite
set.  The mind gets stuck on the recursive declaration of infinite sets,
such as fibonacci, unless one comes from a mathematical mindset.  Math is
a muscle, it atrophies if you do not exercise it.  And similarly to
competitive muscles and aerobic capacity (speaking from my own
experience), it only takes a little bit of exercise to get back to about
60% of former peak ability after a long period of no exercise.

More information about the Haskell-Cafe mailing list