Super-dee-duper D features

renoX renosky at free.fr
Tue Feb 13 13:52:40 PST 2007


Lutger a écrit :
> Pragma wrote:
>> One nit: I agree with Walter here.  People do *not* "naturally think
>> recursively".
[]
> I'm not sure this is true. Many simple tasks are described as 'do X to Y
> until Z,' which can be expressed easily as a recursive procedure.

And even more easily as a loop.

> I doubt non-programmers would think of a task as iterating over a collection of
> objects with mutable state either. :)

Uh?? Take a bunch of potatoes, peel them.
Here you are: people are very accustomed to iterate over a bunch of 
things, changing their state.

> Sometimes I get the feeling that recursion is made out to be more difficult
> than it is, for programming I mean. As an average Joe I do like to learn
> more, but when you look up material on the use of recursion, the vast bulk
> of it pretty much assumes you at least have a pretty good programming
> knowledge and often require mathematics too. </rant>

Agreed here. Recursion is not very complicated, just not 'natural'.

> Recursion just has a nerdy aura around it. It probably doesn't help that
> most programmers are learned to think iteratively too.

And it doesn't help recursion that when you transform a recursive 
function to a tail recursive function so that it's not too slow, the 
result is ugly!

Note that recursion is still a useful tool: when you learn about the way 
to optimize 'Conway's game of life' (couldn't find the url sorry), it 
really show the power of tree representation/recursion, but it also show 
how tricky this is.

renoX




More information about the Digitalmars-d mailing list