r/ProgrammingLanguages • Futhark • Jan 20 '26

Why not tail recursion?

https://futhark-lang.org/blog/2026-01-20-why-not-tail-recursion.html
62 Upvotes

34 comments sorted by

View all comments

Show parent comment

1

u/jsshapiro Jan 22 '26

Fair. Part of my head was still in the other discussion. Though the statement you make here about different optimizations simply isn't true - there's no reason the same optimizations cannot be applied.

Part of why I assumed is that if the language does not require proper tail recursion than function calls and loops are not interchangeable. Without the tail recursion you need to unwind the stack after the function calls. That's pragmatically expensive, and it has implications for deciding termination.

1

u/divad1196 Jan 22 '26

I never said that the same optimization cannot be applied. That's the opposite of what I said.

To make my point in one sentence: loops can have the same level of optimization as (tail) recursion.

I made the statement because the previous comment seemed to say that loops can never be as optimized, which is wrong.

1

u/jsshapiro Jan 22 '26

Sounds like we are in agreement then, Perhaps I got confused while reading across the thread.