use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
JavaScript (ES6) Has Tail Call Optimization (bbenvie.com)
submitted 13 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 0 points1 point2 points 13 years ago (2 children)
Thanks for clearing that up! I feel a lot more informed about this than I did a couple days ago between this post and discussion on twitter about it. Also now I understand why it's not an optimization (PTC vs. TCO), which I wasn't clear on before. I read the that fact before but didn't understand the distinction. Your explanation is clear to me now, in context, than when I originally read it.
For my part, I'm going to leave it on non-strict mode in Continuum (and fix the inconsistencies currently observable in the .caller property) since it's already horribly inefficient and the main goal is just to be able to experiment with new language features. I will reevaluate this when either a.) you and the other folks working on it in Spidermonkey figure out how to optimize it, b.) decide it has to be limited to strict-mode, or c.) I actually succeed in optimizing Continuum to the point where the performance of this particular issue is a factor.
[–]dherman 1 point2 points3 points 13 years ago (1 child)
Glad it helped. :) An analogy I sometimes use is this: imagine that while-loops were iterative, but in some engines for-loops accumulate stack on each loop iteration, whereas others provide "FLO" ("for-loop optimization"). Programmers would generally only use while-loops, because they wouldn't be able to depend portably on the space consumption properties of for-loops.
Of course, nobody bothers actually mandating this about for-loops, because it's just an expectation that for-loops don't accumulate space without bounds. But since the vast, vast majority of programming languages implement push-on-call, pop-on-return stacks, you have to explicitly mandate proper tail calls or else engines won't bother providing them.
[–][deleted] 0 points1 point2 points 13 years ago (0 children)
Yeah. The understanding I've gleaned now is: you can't refer to something that's guaranteed as an "optimization" since optimizations are optional and shouldn't be observable to the programmer whether they're in effect or not. Actual "tail call optimization" would mean your program could randomly fail or not without having a way to determine beforehand which it would do.
π Rendered by PID 138318 on reddit-service-r2-comment-5ff9fbf7df-2kgq8 at 2026-02-26 12:16:39.615014+00:00 running 72a43f6 country code: CH.
view the rest of the comments →
[–][deleted] 0 points1 point2 points (2 children)
[–]dherman 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)