Hey ray tracers out there— what you think? I have done it with and without and have mixed feelings
How often do you *actually* use recursion in your programs?
I'm not sure if I'm the only one here, but I'm going to put it out in the open:
I've been programming for 20+ years, and while I understand recursion… I never use it. Ever. Seriously 🙂
I feel like there's a huge emphasis on recursion in computer science topics because there are seemingly elegant solutions that arise with recursion. It seems to make some algorithms align better from a mathematical perspective, perhaps?
In reality, debugging recursion is a pain. It's also a nightmare to deal with if you have very deep recursion (your call stack gets ridiculous).
I've just never had a need to use recursion in production code. I've found that converting over to an iterative loop based approach is almost always more readable and easier to debug.
And I'm generalizing, of course, but this has been my working experience.
So after 20+ years of writing code, my brain never thinks about things recursively (even though I understand the concept). But it has also never once slowed me down 🙂
What's been your experience using recursion in production code bases? Do you use it just because it was there, or did you add it in with purpose? I'd love to hear!