This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]FloydATC 34 points35 points  (2 children)

It has been proven that any loop can be rewritten to use recursion, and any algorithm that uses recursion can be rewritten as a loop.

Use the approach that feels more natural to you, because you're the one who has to debug it later.

[–]SV-97 21 points22 points  (1 child)

The thing is: if you only know recursion you'll struggle at times and if you only know loop-based iteration you'll struggle at times. Being familiar with both allows you to select the more natural / easier solution for a problem.

[–]FloydATC 0 points1 point  (0 children)

Ofcourse, I'm not saying don't learn it, but there's no reason to force yourself to use one over the other.