3 ms·
> the idea that for loops are somehow easier than recursion is definitely not from mainstream CS I have never in my life heard a programmer say they think recu
by l33t233372 4y ago
> the idea that for loops are somehow easier than recursion is definitely not from mainstream CS
I have never in my life heard a programmer say they think recursion is easier than loops.
- kazinator 4y agoThat only shows you haven't known any programmers who had a broad exposure to the topics of their supposed craft; it doesn't speak to the actual topic itself. Recursive solutions being easier to verify is quantifiable. This is not some popularity poll. Some people are not well-versed in some techniques. Recursion is not always well supported in programming languages. In standard C if we want to use recursion, we will have to write multiple standalone functions that have their own scopes, whereas if we put together several loops, we can have those all in the same scope, with convenient access to common local variables. That could make a decisive difference. Not all languages have tail calls; what looks like tail recursion can "blow the stack". When I say that it's "easier" I don't mean that anyone of any skill level and background can more easily design and implement a recursive solution for any problem, and in any language. Rather, that when the recursive solution is discovered, it is easier to convince oneself that it is correct: that it's handling all the cases and terminates, with the correct value.
- l33t233372 4y ago> Recursive solutions being easier to verify is quantifiabl Ease of doing something is a quantifiable description?
- preseinger 4y agoverifiability is not an important property of a program, except in very niche circumstances