Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Fun fact: NASA coding standards forbid using recursion, for any reason, ever. Not saying recursion is good or bad, I just read that the other day and thought it was interesting
-
Root825997y@LuckierDodge
It makes sense. Typically, recursion:
• Is harder to code
• Is harder to debug
• Has increased resource usage
Depends on the specific use case and implementation, ofc. -
maestro9717yWith loops I take at least 5 minutes to be sure that my code won't get an ArrayOutOfBoundsException especially when my loop condition uses someVar - 1 or someVar.
-
@Root Also, if your algorithm has branches, you need to make sure you don't pass twice in some branches. Fibonacci with recursion is a classic example of this.
I used to prefer, think, and code in loops rather recursion.
Now though somehow it's the other way around...
And I have to assure myself why a piece of code I wrote won't cause a Stack overflow... and that if I really had to I could convert it back to a loop.
Haven't done it though for a awhile tho...
rant