C loops are natural and easy to understand for programmers who were trained on loops. I doubt that tail recursion is any harder to get for students who don't have that background. Would be an interesting experiment though.
Iteration is more natural for most people than recursion. There are a few aliens for whom recursion is more natural, but iteration matches more closely daily life.
I think recursion is just another tool in the toolbox: sometimes, some solutions are easier to think of recursively, and so it makes sense to use it, at least for the first prototype.
But yeah, using it systematically (in a non-functional language) is unwise.
I think its fairly clear that loops are more natural and obvious for most people for most tasks.
There are examples of other communities which have invented something pretty much the same as loop syntax, for example you get things which are basically loops in knitting patterns or (less reguarly) in recipes. I have never seen an example of recursion outside computer science/programming.
This is what happens when we eliminate shop class. Sand this table leg. Good. Now do that three more times. Kids used to know loops before they ever touched a computer.
C doesn't have a "do this 3 times" loop though. It has an "initialize counter to 0 first, increment counter after each operation, and compare the counter to 3 (or is it 4?)" loop. Kids definitely don't get this without being taught.
Need four legs, have none. Doing while I don't have enough. How many legs do I have? 1. Doing. How many legs do I have? 2. Doing. How many legs do I have? 3. Doing. How many legs do I have? 4. Done.
Alternatively:
for (int i=0;i<4;i++;) {
//how we start; whether we repeat; how we update our counter.
Sand_leg();
}
You only need to sand a leg when you don't have enough legs.
These aren't that far off of actual things you'd do moving about. In fact, not realizing that you're distilling something physical into the symbolic is a leading cause of confusion in my experience.
A "do x times" dedicated looping construct would be syntactic sugar that detracts from understanding what the underlying semantics are; which if you're teaching how to program is a bad idea. The idea is to have your understanding precede the machine. Not lag behind.
You can start screwing around with abstractions after you get the basics. As once you have the basics, you can compose them into any form you want.
The rest is just increasing levels of crippling mental illness.
How do you measure beauty? You can't: "beauty" is subjective. And even if you try e.g. count the times you use recursion vs. iteration: that metric is subjective and not grounded in reality.
Sometimes recursion does allow you to reason about code more easily or come to a working solution faster, sometimes it does not.
Measure the concrete: CPU time and memory consumed. Iteration will likely trump recursive methods w.r.t both these metrics. If it doesn't, you can likely transform your iterative algorithm to one that utilizes SIMD (not always).
> How do you measure beauty? You can't: "beauty" is subjective
Let me try: in classical dance, martial arts, or even skateboarding, advanced skills manifest as effortlessness: the movements comes naturally, they're not forced, things just flow.
If you compare a typical functional (recursive + pattern matching, but the point would stand even with a fold) factorial with an imperative one (for loop), the functional approach is more effortless, you have to be less explicit about what's going on. It's more eloquent.
However as you seem to imply, when we're programming, the focus should be on delivering something that works as expected; this particular kind of aesthetic is secondary at best.
This is a painfully stemlord response. 'Aesthetic qualities cannot be objectively measured therefor they do not exist'. Christ. Its fine to pick a metric to evaluate one thing against another, its another to deny that there are other ways to value things.
I never understood anyone who used such strong language like "beauty" when talking about something mundane like recursion. I suspect it's just in-group language like how a cult understands the meaning of their own words, while to outsiders it would appear nonsensical. I have seen other groups appropriate the word "beauty" too, like people who chronically overeat.