A good friend once told me: “to understand recursion you have to understand recursion”. Being a music major at the time, I didn’t get the joke, but now it seems depressingly accurate. Up until now, anything I tried to do using Python was more difficult for the computer than it was for me: I needed complicated sets of for loops and if statements, accounting for every last possibility, to answer questions that I can do myself without even a pen and paper (Where do words begin and end? Is this a sentence? Did I get a passing grade or not?) Recursion is a different story - I type a few lines of code, the computer zooms through it, and 20 minutes later I’m still trying to figure out how the heck it worked.
Which isn’t to say it’s not a really interesting and useful concept. Defining something in terms of itself is a surprisingly efficient way to get things done. But it also requires a different way of thinking than anything else I’ve encountered in programming so far. You need to put a lot more trust in your computer, and, to some extent, in yourself. And it’s uncomfortable; it’s a leap of faith. But if you just assume that, at a basic level, you can understand recursion - then you can understand recursion.
No comments:
Post a Comment