3 ms·
They're loops with stronger semantics (in other words, they're more restrictive (in other words, they're easier to reason about)), in the same way that loops th
by kibwen 3y ago
They're loops with stronger semantics (in other words, they're more restrictive (in other words, they're easier to reason about)), in the same way that loops themselves are `goto` with stronger semantics.
- kelseyfrog 3y ago> they're more restrictive (in other words, they're easier to reason about)) That's a great point. Often in my programming career, I've used the rule of least power[1]. In the looping/flow control ladder, I'd list descending * JMP/GOTO * for/while * map/filter/reduce If a problem only needs a map, using a for introduces needless complexity(ie: state). Personally, I think we have a pedagogical problem in that we teach people loops first and people confuse what they've been taught first with what is a reasonable choice[2]. For completeness, recursion has it's own ladder * PUSH,POP,JMP * function call * recursion schemes[3] Side note: recursion schemes have an enormous hurdle to adoption in that mathematicians got there first and the naming are so off putting that no one will take you serious if you bring up even simple schemes like anamorphism and catamorphism. Folks would rather accept a FactoryFactoryFactory over a futumorphism. 1. https://en.wikipedia.org/wiki/Rule_of_least_power https://en.wikipedia.org/wiki/Rule_of_least_power 2. The other side of this coin is, "Why would they teach me a bad way of doing something?" 3. https://github.com/passy/awesome-recursion-schemes https://github.com/passy/awesome-recursion-schemes
- accrual 3y agoViewing loops as a stronger GOTO is a really interesting perspective which makes sense to me, thanks for the insight.
- otikik 3y agoI see them as a restricted (so, less powerful than a goto). That’s why they are better. Perhaps that’s what you meant when you said “stronger”
- deleted 3y ago[deleted]