3 ms·
Recursion is hard, but it is a fundamentally great tool. If I talk to someone who doesn't understand programming, they can usually understand the if and for st
by icc97 9y ago
Recursion is hard, but it is a fundamentally great tool.
If I talk to someone who doesn't understand programming, they can usually understand the if and for statements that you might find in food recipes or in legal contracts.
But almost nowhere outside mathematics and computer science (and certainly not as common as recipes) do you come across recursion.
It's mentally hard to think of a problem so that each step gets simpler.
Solving the towers of hanoi is not straight forward, I can't follow it at the speed that I can read as I could with basic math, I have to really think if what they are suggesting works and how does it work.
However when you get to solving hard problems, recursion really helps. I know from having spent hundreds of hours with interview questions. Bugs can make a problem go from taking me 30 minutes to 4+ hours. Where as using recursion and other functional programming concepts, once I got to the solution it would usually be bug free. So whereas it might not be as fast, I would be more confident in my final answer.