31
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 22 Dec 2023
31 points (91.9% liked)
Programming
17314 readers
159 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 1 year ago
MODERATORS
As a rule of thumb, I would say that recursion should never be used in place of a for loop.
If you don't know what you're doing with a recursive function then you risk pushing stuff to your call stack proportionally to the number of items you want to iterate over.
If your collection and/or the size of the stuff you're pushing to the stack is large enough, your app will crash.
If you know enough to avoid growing the call stack then you know enough to not rely on third parties to figure out if you need an iteration of recursion.