me again

  • 14 Posts
  • 84 Comments
Joined 1 year ago
cake
Cake day: September 4th, 2023

help-circle



  • 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