• @[email protected]
    link
    fedilink
    3
    edit-2
    7 months ago

    depends on the language and the compiler, pretty sure gcc without at least -O2 doesnt do tail call elimination(and still itll be slower than iteration), and rust didnt have it/low priority and when i was introducing myself to js it didnt have tco everywhere either. so just write in a way that is idiomatic to your language. in haskell recursion is encouraged, in part because it is guaranteed that it will be optimized by the compiler.

    regardless of the language if your recursive function is poorly designed, its going to result in stack overflow with sufficiently large inputs