[Haskell-cafe] Re: Channel9 Interview: Software Composability and
theFu ture of Languages
magnus at therning.org
Wed Jan 31 10:48:21 EST 2007
On Wed, Jan 31, 2007 at 09:43:36 -0500, Mark T.B. Carroll wrote:
>Magnus Therning <magnus at therning.org> writes:
>> Sequential thinking would be related to procedural programming, that is
>> ordering of statements are important but there's no state. Functional
>> programming is declarative, no order and no state. So, to be strict I'd
>> say that sequential form _is_ non-functional. At least if FOLDOC is
>> correct and I read and understood things properly.
>You've completely lost me here. Order is /very/ important in functional
>programming. Consider function composition:
>Prelude> ((+1) . (*2)) 5
>Prelude> ((*2) . (+1)) 5
>There we have sequencing, and the computation has intermediate state.
>There's nothing non-functional about the above.
What you have written above are two mathematical expressions:
2 * 5 + 1
(1 + 5) * 2
Now, correct me if I'm wrong, but you see a "natural" ordering in your
haskell expressions, right?
However, I don't think there's any pre-defined ordering of the
_calculations_ the computer performs in your _equations_ above. In the
first one, there isn't much freedom at all due to mathematical rules,
however in the second one we have a few choices:
- distribute *2 over the parenthesis
- calculate the left product, calculate the right, sum it up
- calculate the right product, calculate the left, sum it up
- compute the sum in the parenthesis, multiply the two factors
No matter which is chosen we end up with the same result. So, in the
end we don't care about the sequence. However the compiler/interpreter
has to choose a sequence in order to arrive at a result, since that's
how today's computers work. (Choosing well can be seen as optimisation
I know the example here is a bit contrived, but I didn't want to move
away from your example.
In short, AFAIU:
I don't care how you do it, just get it done!
You'd better do things in this order!
You should do it exactly like this!
Oh, if I've fundamentally misunderstood things then I'd love to hear it
Magnus Therning (OpenPGP: 0xAB4DFBA4)
magnus at therning.org Jabber: magnus.therning at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070131/1d2eee60/attachment.bin
More information about the Haskell-Cafe