My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Given a choice, would you choose an iterative approach or a recursive one?

Mohammed Ismail Ansari's photo
Mohammed Ismail Ansari
·Jul 29, 2019

Iterative

71%

Recursive

29%

17 votes · Closed

It's beautiful how the same problem can be solved using an iterative or a recursive algorithm, both having their own advantages and disadvantages. Personally, I first got familiarized with looping structures and was fairly comfortable thinking that way (I imagine it's the same for most of us back when we started). My first encounter with recursion was a scary one (I was specifically made to fear it) and it took me a couple of years to actually try it myself and get comfortable with the concept and then it did not take much time to fascinate me.

Having watched quite a lot of lectures from SICP on YouTube a few years back (still did not get through the entire list), and having used them in most of my implementations at work and in my personal projects, I still like recursive algorithms. Furthermore, concepts like tail recursion make it even interesting.

However, I read an awesome post recently and it talked about so many disadvantages of using recursion, most of which I do agree with myself. There were a few comments about that recursive vs iterative thing, but I just wanted to ask to the community, for if you had a choice, what would you rather go with: an iterative approach that is easier to understand (as most of our minds are trained that way) or a recursive approach (that feels very functional)?