by LudwigNagasena · 2y ago · 0 comments
> Look! I replaced this recursive function with a for loop and it still does everything that we need it to. I know it’s not as clever, but I noticed that the interns were having trouble with it and I thought that this change might help.
Recursion is not clever, it is not a trick. It's a basic technique kids learn in high school in Advanced Placement CompSci A. I do not want to work with people who know less about their professional field of choice compared to kids. And if the educational system has failed interns, at least let them learn what recursion is on the job! Isn't that what internship is for anyway?
Honestly, I don't even get the sentiment. Many problems are naturally formulated in terms of recursion. And rewriting them as loops would be considered an optimization technique that obfuscates the reasoning.
It's not an optimization so much as it is non-pessimization. You have a lot less control over how your runtime's call stack behaves, which means that basic things like error handling, memory usage, observing intermediate state, etc. all become much more inconvenient (if possible at all).
but: for me simple is to have a short and concise solution of a problem/ requirement that does exactly what is required and not more.