Hacker News new | past | comments | ask | show | jobs | submit login

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.




This 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_metho...


I believe he's more concerned about issues where tail-calls aren't possible or attractive.


It depends on the language. Many good languages are designed to handle recursion safely.

For some, it’s practically the only way to loop.


Looks 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.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: