Fergus wrote:

> I guess one could argue that the costs of most other things pale
> in comparison to the costs of having lazy evaluation as the default ;-)

Of course, if you're the sort of person who likes to write "head (sort lst)"
to get the least member of a list, then lazy evaluation is incredibly
efficient. Getting used to lazy evaluation, and really learning how to use
it properly, is probably really the hardest thing about Haskell for someone
who has already learned how to program using strict languages. Possibly even
harder than monads.

Funny/sad anecdote: I once saw a senior software engineer with over 15 years
of C experience and a master's degree in CS, write the following code in C
to locate the least member of an array:

    qsort(array,
          sizeof(array) / sizeof(array[0]),
          sizeof(array[0]),
          comparator);
    least = array[0];

Essentially, this is just "head (sort lst)" in C, which, as I daresay we all
know, is NOT a lazy language! I actually had to explain to her why it was
inefficient. Depending how you look at it, this is either strong evidence
that lazy evaluation is a more natural way to think than strict evaluation,
or proof that a master's in CS doesn't necessarily mean you really know
anything about programming.

Craig



Reply via email to