Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't think many people consider tail calls more intuitive than a while loop. The opposite is more obvious.


> I don't think many people consider tail calls more intuitive than a while loop. The opposite is more obvious.

This depends a lot on the background of the respective person. For someone who is more trained in classical mathematics, tail calls are more intuitive (or rather: nearer to their knowledge base) than while loops.


While the formal concept of applying a function that calls itself may be more familiar to someone trained in classic mathematics, everyone is somewhat familiar with while loops, from basic life things like 'while hungry, eat' or 'salt to taste -> while (not_salty_enough()): add_salt()'


I've successfully explained a while loop to many a child, and adult, with no experience in programming, within about 5 minutes.

I'm absolutely sure the people who think tail recursion is any way similar, in complexity, to a while loop have never attempted to teach someone how to program.


add salt; not salty enough?; do same again!

The explanation is just as simple translatable, even saving one the words like "while" or "until".


I mean "for" and "while" loops are effectively used in natural language all the time, even to the youngest of kids.

"Do this action 10 times" "Put one item in each box"

I fail to see how recursion is /more/ intuitive, in pretty much every (english) language construct I can think of the condition is separate from the action.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: