News for hackers. Stuff that matters.
Re:Misconceptions about loops in C by duped on Thursday June 27, 2024 @04:28PM (#40814738)
I don't think many people consider tail calls more intuitive than a while loop. The opposite is more obvious.
Re:Misconceptions about loops in C by aleph_minus_one on Thursday June 27, 2024 @05:15PM (#40815200)
> 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.

Re:Misconceptions about loops in C by gabrielhidasy on Thursday June 27, 2024 @05:52PM (#40815561)
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()'
Re:Misconceptions about loops in C by nomel on Thursday June 27, 2024 @10:47PM (#40817270)
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.

Re:Misconceptions about loops in C by zelphirkalt on Friday June 28, 2024 @03:36AM (#40818536)
add salt; not salty enough?; do same again!

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

Re:Misconceptions about loops in C by kimixa on Thursday June 27, 2024 @09:40PM (#40816987)
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.