News for hackers. Stuff that matters.
Re:Misconceptions about loops in C by chongli on Thursday June 27, 2024 @03:58PM (#40814439)
Recursion is more natural and deeply-engrained than people realize. Natural language has a recursive grammar:

My dog => My friend's dog => My father's friend's dog => My father's sister's cousin's nephew's teacher's friend's plumber's dog's chew toy.

We can construct sentences like this with a completely arbitrary level of recursive nesting. It's so natural that people do it without thinking about it. Recursion only becomes unnatural when we prime people on it and get them thinking it's scary and complicated.

Re:Misconceptions about loops in C by atorodius on Thursday June 27, 2024 @04:12PM (#40814579)
I don’t think this is true at all. I remember vividly when I learned about loops („oh it is just the statement multiple times“) vs learning recursion (spending 3d on an assignment from uni and scratching my head and not getting how the heck this makes sense)
Re:Misconceptions about loops in C by slashdave on Thursday June 27, 2024 @04:24PM (#40814694)
So natural, yet the specific example you provide is broken
Re:Misconceptions about loops in C by AlotOfReading on Thursday June 27, 2024 @04:26PM (#40814714)
I'm surprised you consider that construction "simple". Recursive relationships like that are used for brain teasers and even a famously absurd joke in Spaceballs.

    Darth Helmet: I am your father's brother's nephew's cousin's former roommate.

    Lonestar: What does that make us? 

    Darth Helmet: Absolutely nothing.
In fact, standard English tends to avoid recursive relationships with specialized kinship terms based on ordinals like first cousins, first cousins once removed, great-, and so on.
Re:Misconceptions about loops in C by chongli on Thursday June 27, 2024 @04:29PM (#40814746)
I'm surprised you consider that construction "simple".

It's VASTLY simpler than the alternative. See how difficult it is to express the same relationship without using the recursive grammar.

Anyway, give anyone a family tree diagram containing all of these relationships and they can follow the chain from that sentence to the destination. This is the essence of why we use recursion in computer science in the first place: it's the best tool for navigating trees.

Re:Misconceptions about loops in C by com2kid on Thursday June 27, 2024 @06:16PM (#40815784)
> Anyway, give anyone a family tree diagram containing all of these relationships and they can follow the chain from that sentence to the destination. This is the essence of why we use recursion in computer science in the first place: it's the best tool for navigating trees.

This is because English sucks at tree relationships. Other languages are much better at this.

For example, Mandarine Chinese has unique words for each side of the family tree (e.g. unique word for Grandma on mother's side vs Grandma on Father's Side), and also a rather logical system to describe how you navigate the tree.

Chinese isn't even unique in this, it is just that English is really really bad.

Re:Misconceptions about loops in C by dfawcus on Friday June 28, 2024 @11:01AM (#40821306)
Is having a unique word that much of an improvement over "paternal grandmother" vs "maternal grandmother"?

Or is it that you're referring to other relations than those two having unique words? If so then that would seem to introduce its own problems in ballooning the vocabulary.

Maybe English is just happier with the ambiguity?

Re:Misconceptions about loops in C by com2kid on Friday June 28, 2024 @11:48AM (#40821843)
One word helps make it easier.

I got very tired, very quickly, even as a kid, of saying "Grandma on my Dad's side".

I had two Uncles with the same name, again, "Uncle <foo> on my Dad's side" is a PITA after awhile.