r/javascript • u/fagnerbrack • Jul 20 '26
Your Recursion Is Lying to You
https://blog.gaborkoos.com/posts/2026-05-09-Your-Recursion-Is-Lying-to-You/
0
Upvotes
r/javascript • u/fagnerbrack • Jul 20 '26
View all comments
Show parent comment
4
u/A1oso Jul 20 '26
Many optimizations of systems programming languages (C, C++, Rust...) can reduce stack usage so much that the unoptimized program overflows the stack when the optimized program does not, even without tail call elimination. Likewise, optimizations for managed languages like Java and JS can reduce heap memory usage, preventing "out of memory" errors. The guarantee that compiler optimizations don't change a program's behavior relies on the assumption that there is sufficient stack and heap memory to execute the code.