DEV Community

loading...

Discussion on: The Story of Tail Call Optimizations in Rust

Collapse
stefanod profile image
Stefano

Even if the library would be free of additional runtime costs, there would still be compile-time costs.
Is TCO so important to pay this overhead?

Collapse
seanchen1991 profile image
Sean Chen Author

That's a good point that you raise: is TCO actually important to support in Rust?

I think to answer that question, we'd need data on the performance of recursive Rust code, and perhaps also how often Rust code is written recursively.

In my mind, Rust does emphasize functional patterns quite a bit, especially with the prevalence of the iterator pattern. Despite that, I don't feel like Rust emphasizes recursion all that much, no more than Python does from my experience.

So perhaps there's an argument to be made that introducing TCO into rustc just isn't worth the work/complexity.

Forem Open with the Forem app