4 ms·
In my opinion, that's not really such a big deal. For example, Python does not optimize tail calls, but supports many functional idioms anyway and is quite ple
by bbb 18y ago
In my opinion, that's not really such a big deal.
For example, Python does not optimize tail calls, but supports many functional idioms anyway and is quite pleasant to use.
So, yeah, having tail call optimization be a mandatory part of Javascript would be cool from a language nerd point of view, but it would have very little practical impact.
- qwph 18y agoYeah, but, if you can't rely on tail-call optimization, you can't really use recursion and expect your code to handle any arbitrary amount of data that's thrown at it. To write robust code, you're forced to use iteration instead. The difference between O(1) and O(n) memory usage is a big deal, IMHO...
- bbb 18y ago> To write robust code, you're forced to use iteration instead. That's exactly the point. You can use nice functional idioms in Python as long as you make the main loop(s) that crunch data iterative. Same thing in Javascript. Adding tail-call optimization adds little to Javascript; it's nice to have but has no high return on investment (in terms of the effort you put into the language vs. what becomes impossible if you omit it). Case in point: Think of all the criticism directed at Python. The lack of tail-call optimization is not voiced very frequently.
- ardit33 18y agothat's a huge step back for computing. The point of recursion is that it makes really hard problems simple to solve.
- earthboundkid 18y agoIt makes some hard problems simple to solve. Other times you end up wasting a lot of time figuring out how to send the return value to an accumulator without accidentally creating an infinite loop or doing things twice. Anyway, in Python you can always fake TCO using decorators. As long as someone invents the same thing for Javascript, no harm, no foul.
- raganwald 18y agoI know you are being sincere in raising your doubts, but please keep this in mind: Even if you do not receive 100 arguments and careful essays explaining the value of TCO and comparing inductive vs. iterative algorithms, that doesn't mean that those arguments do not exist. It's just that Language feature X is clearly unnecessary because Language Y has feature Z instead, and I'm perfectly happy programming in Y has been raised, refuted, defended, and debated so many times that the people with the most experience arguing either side of it are the ones who are least likely to consider trotting it out again productive, and the people with the least experience are most likely to find arguing it again productive and intellectually rewarding.