17 ms·
I try to avoid recursion, I don't want to blow out the stack. Personally I think it should not be used for implementation, I consider it to be a security risk.
by rdaystrom 5y ago
I try to avoid recursion, I don't want to blow out the stack.
Personally I think it should not be used for implementation, I consider it to be a security risk. It's ok for high-level pseudocode.
- macintux 5y agoIt depends on the language. Many good languages are designed to handle recursion safely. For some, it’s practically the only way to loop.
- siraben 5y agoThis isn't true if your language does tail-call optimization[0]. > I consider it to be a security risk. Again, non-issue if your language handles recursion properly (and in some languages like Haskell, "blowing the stack" is not a thing that happens). [0] https://en.wikipedia.org/wiki/Tail_call#Implementation_methods https://en.wikipedia.org/wiki/Tail_call#Implementation_metho...
- nights192 5y agoI believe he's more concerned about issues where tail-calls aren't possible or attractive.
- waynesonfire 5y agoLooks like you learned something new. You now also have a guage to measure the sophistication of a programming language. Ask if it supports tail call optimization and move on if the answer is no.