>>12 Recursion is easily understood. The temptation to simplify algorithms with it is pervasive.
I understand the motivations to increase code density. Its “elegant” and “concise” but its implementation destroys performance. Consider that every recursion (which is not tail-recursive) carries the penalty of
1.Function call
2.Parameter evaluation
3.Function logic overhead(it executes through code supplied by parameters)
4.Context store and load. Every recursion must return to context. It takes time.
5.Waste of stack space.As above, the calls,especially nested ones will pollute the stack if used in any programs.
_______________________________________________
The world breaks everyone and afterward many are strong in the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.