Apparently, there’s been a big brouhaha over whether or not Python needs tail-call optimization (TCO). This came to a head when someone shipped Guido a copy of SICP, because he didn’t “get it.” I’m in the same boat as Guido. I understand the concept of tail-call optimization. I just can’t think of any reason why Python really needs it.
To make this easier for me to understand, what would be a snippet of code that would be greatly simplified using TCO?
Advertisement
Answer
Personally, I put great value on tail call optimization; but mainly because it makes recursion as efficient as iteration (or makes iteration a subset of recursion). In minimalistic languages you get huge expressive power without sacrificing performance.
In a ‘practical’ language (like Python), OTOH, you usually have a lot of other constructions for almost every situation imaginable, so it’s less critical. It is always a good thing to have, to allow for unforeseen situations, of course.
Personally, I put great value on tail call optimization; but mainly because it makes recursion as efficient as iteration (or makes iteration a subset of recursion). In minimalistic languages you get huge expressive power without sacrificing performance.
In a ‘practical’ language (like Python), OTOH, you usually have a lot of other constructions for almost every situation imaginable, so it’s less critical. It is always a good thing to have, to allow for unforeseen situations, of course.