I find that recursion is something that in simple cases can be replaced with a loop, and in complex cases is hard to reason about and therefore should be avoided.
Recursion is just spiral reasoning. It looks like circular reasoning, but if you keep going with it the curve keeps getting smaller until eventually you reach the trivial case.
I have myself tried to explain recursion many times to those who do not understand it. While I do well, this is significantly more succinct than what it would take for me to succeed with most, and provides a clear visual. Nicely done.
I don’t think recursion is that hard to reason about. You need an understanding of how to work with it. This requires practice in the same way dealing with trigonometry required that.
If you are a programmer and feel that dealing with recursion is hard I think you’ve got an opportunity for growth there.
It’s true that recursion is harder to deal with than loops. I generally use loops and recursion for a different class of problems.
Working with trees of arbitrary depth is much easier when using recursion.
17 comments
[ 2.5 ms ] story [ 47.4 ms ] thread> Recursion (rĭ-kûr’-zhən) noun. See recursion.
I like this version:
To understand recursion, you must first understand recursion.
I also like self-referential music, such as Carly Simon's "You're so vain"
> You probably think this song is about you
I’ll probably be stealing that metaphor.
If you are a programmer and feel that dealing with recursion is hard I think you’ve got an opportunity for growth there.
It’s true that recursion is harder to deal with than loops. I generally use loops and recursion for a different class of problems.
Working with trees of arbitrary depth is much easier when using recursion.