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.
> 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.
Aren’t loops just wrappers around goto and if statements?
The claim is that by expressing programs in terms of these array primitives, you (a) can have those primitives be super optimised and (b) better see what the program is actually about without worrying too much about eg what names to give all the loop counters, all the other intermediate state associated with iteration, etc.
Loops themselves can be considered just convenient wrappers around goto. The point is to restrict the variety (structured programming) and make spaghetti unreadable code less likely.
Using higher-order functions instead of loops is similar e.g. loops:
# input_ = "1,2,3"
numbers = (int(d) for d in input_.split(","))
product = 1
for n in numbers:
product *= n
Sure, and C is a convenience wrapper around assembly and assembly is a convenience wrapper around toggling octal codes on your front panel and punching in octal code is a convenience wrapper around rewiring vacuum tubes and relays and that's a convenience wrapper around mechanical cogs and that's a convenience wrapper around an abacus.
But it's a different paradigm than procedural programming and embracing it might lead to a different mind set.
Lol. IMO the difference between an C and Assembly (as between vacuum tubes and the abacus) is really a difference in power, since it allows the same program to be implemented on different architechtures. It's only fair to start calling things convenience wrappers once you get past C. And often enough, an abstraction aimed at convenience leads to a reduction in expressive power.
Loops (Eg: in C) are a much “wilder” construct — something special could happen for i=17 or successive iterations might overwrite values, etc. more restrictive “tamer” versions help programmers & computers reason about the code.