Iteration vs Recursion… Or Andre vs Sabre.

So, I dig pro wrestling.  Pretty much always have.  It’s a curse, for sure.  There’s really no cool way to tell your friends that you can’t go to the pub because you’re going to spend your night watching oiled up men express impotent rage at one another before engaging in a pre-determined act of PG friendly fist a cuffs.  I am who I am, man!

Either way, let’s take my embarrassing pass time an make something useful out of it.  In programming you have two major paradigms that are fairly important to understand when building out algorithms.  One is Recursion and the other is Iteration.  Now, iteration is like Andre the Giant… This guy.

5+andre+the+giant+facts

I mean, how could anyone not think that’s cool?  Either way, Andre is like iterative ideas about building out algorithms.  He’s well known, easy to understand, and pretty cool at first glance.  The ugly truth is, and I do mean ugly, is that Andre kinda sucked as a pro wrestler.  I mean, we was big, for sure – and his strength was prolly pretty high – but when it came to the art of wrestling, he was just kind of a stiff, hulking worker who only had like 5 moves.  Iterative principals are similar to that.  Everybody knows ’em (programmers = everybody), but really they can be kind of stiff.

Now lets talk about another guy:  This is Zack Sabre Jr.

jack

I know, right?  Why would anybody ever like this guy?  I mean, the hair, the jacket, hell – he ain’t even huge, man!  Oh, but dear friends, if ya just saw him in action!  I mean, he’s like beyond versatile!  High flying one minute, technical ‘on the mat’ wrestling the next, chaining together submission at a dizzying pace.  Ah, it’s like art, man… Let’s compare Sabre to recursive paradigms.  At first glance you have a hard time understanding why anyone would like them.  It’s just overly confusing, man!  Iterative does the same thing!  Well, iterative and recursive do do the same thing in the same way that good ole Jack Sabre and Andre both wrestle.  It’s the subtle differences, man!

A recursive function is one that calls itself again and again in the code until a given answer is reached.  This, at first glance, seems counter intuitive and a bit confusing.  Just like my man Jack Sabre.  Fear not, though, once you get into the swing of working in a recursive manner you will wonder who you ever held iterative up on such a weighty pedestal.  Huh, just so happens I made a video tutorial about!  You lucky bastard… Watch, enjoy, get into pro wrestling in your spare time and then lie to your friends about it.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s