[Haskell-cafe] Re: Channel9 Interview: Software Composability and
theFu ture of Languages
Dougal Stanton
ithika at gmail.com
Thu Feb 1 04:24:03 EST 2007
Quoth Magnus Therning, nevermore,
> I'm not sure how a "functional" recipe would look, maybe something like
> this:
>
> White_sauce is a combination of ... .
>
> Chopped_onions is onions cut into small pieces.
>
> White_sauce_with_chopped_onions is the combination of white_sauce and
> chopped_onions.
The functional approach
> whitesauce = foldl stir base milks
> where base = flour + (heat butter)
compared with the imperative
> whitesauce
> base = flour + heat(butter);
> while (milks > 0)
> stir(base, milk);
> milks--;
I'm going to go out on a limb here and suggest that, like Feynman's
example of how people count in their heads, both of these explanations
are accurate. If I were to explain the process to someone it would be in
the imperative style: literally "giving commands", which is what a
recipe is. But in my mind I imagine it as the gradual process of
stirring milk into a base, which is far more adequately described in the
functional style.
The question is --- how would an expert describe such a process? Would a
professional chef give instructions in the functional or imperative
style? I think that is relevant, since the approach to the problem may
change depending on proficiency. We may *learn* in the imperative style
but *think* in the functional.
Cheers,
Dougal.
More information about the Haskell-Cafe
mailing list