HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
tc39
proposal-ptc-syntax
HTML2016–2023
tc39 / proposal-ptc-syntax

proposal-ptc-syntax

Discussion and specification for an explicit syntactic opt-in for Tail Calls.

15Distinct people
17Mentions
0Explicit recommenders
170GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Discussion and specification for an explicit syntactic opt-in for Tail Calls.

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 1:49:46 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year17 dated mentions

Observed mentions: 2016-04-23 18:56:01 UTC to 2023-12-31 15:52:46 UTC.

0123452016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 5 mentions; 0 submissions, 5 comments20162017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 4 mentions; 0 submissions, 4 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments2019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments20192020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 4 mentions; 0 submissions, 4 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC505
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC404
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC312
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC000
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC000
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC000
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC404
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC101

What Hacker News says

17 sources
This is not actually about Tail Call Optimisation, which is more flexible and optional matter of optimisation, but about Proper Tail Calls, which are a guarantee made in the ECMAScript 6 specification (over implementer concerns objections)—in strict mode, calls in tail position must not create additional stack frames. This is the last piece of ECMAScript 6 that most engines haven’t implemented, because it’s rather controversial: it actually causes some performance problems, and makes debugging harder, and may have security issues (in 2016, Mozilla declared it impossible to implement across realm boundaries due to their security model). https://github.com/tc39/proposal-ptc-syntax has a lot of useful information about it all, and a proposal to make it explicit in syntax, such as with `return continue …`, though I don’t believe that’s really
Read the rest
gone anywhere. The practical situation is that this is the one part of the ECMAScript spec that most implementers ignore, and thus which you can’t depend on. Which says to me that it should either be made optional or be removed from the spec. Not sure if there are any other features similarly disregarded. ECMAScript specification policy was different in those days, they operated more independently of implementers. (HTML was like that once too—that’s roughly why WHATWG was formed, because the actual implementers weren’t happy with how things worked in W3C, so they took matters into their own hands.) (Fun terminology problems here. The term TCO is commonly used for PTC, and PTC is very close to being a subset of TCO, but the mandatory stack frame elision which ruins debugging feels to me like it falls outside of TCO. In various situations, debuggers will mark things like “stack frame omitted” when they’ve optimised one out of existence, but you can generally compile things differently, or something like that, to prevent this. (Compiled/dynamic language variation showing up here.) But with PTC, it feels like the engine is kinda not even allowed to know that a stack frames may be absent. So I say PTC and TCO are a little distinct, though PTC is mostly just a subset of TCO. Reminds me of the terminology of tree-shaking versus dead code removal—where the former is essentially a subset of the latter, but that the effects are just slightly different, though I’d say it’s more slight in that case than this.)
In Bun, JavaScript, and TCO
Safari has tail-call optimisation. We don’t have it elsewhere mostly because Google: 1. Agreed to implement it [it’s in ES6] 2. Implemented and shipped it behind a flag 3. Unshipped it. 4. Proposed something else [ https://github.com/tc39/proposal-ptc-syntax ] Prior to that, Firefox had proposed a carve out for cross-realm calls, but then they didn’t bother implementing anything. While apple is against Syntactic tail calls, they’re mainly just opposed to versions of it that would remove/unrequire the tail-call optimisation they already do: https://github.com/tc39/ecma262/issues/535 For the version of it that is backwards compatible, they wouldn’t need to do anything other than ignore the syntax. Their main concern is that it "could add confusion with very little benefit."
In Tell HN: We are trying to get tail calls into the WebAssembly standard
The spec for STC has a critique of PTC: - performance - developer tools - Error.stack - cross-realm tail calls - developer intent See: https://github.com/tc39/proposal-ptc-syntax#issues-with-ptc Apple's 2016 response as to why they won't implement STC is here: https://github.com/tc39/ecma262/issues/535 - STC is part of the spec and will take too long to change. - Now that they've implemented support for PTC, they don't want to regress web pages that rely on it. - They don't want to discourage vendors from implementing PTC by agreeing to STC. - They don't want to introduce confusion. Some of these arguments about confusion and delays seem wrong hindsight, since on every point things would have been better if they'd just agreed to the compromise of STC. - It would have been part of the spec years ago - STC would have had a clear way for web
Read the rest
pages to know when tail calls could be relied on (and PTC would have been optional) - Other vendors didn't implement PTC in any case, despite no agreement on STC - There's even more confusion as things are now
In What happened to proper tail calls in JavaScript? (2021)
I agree, syntactic tail calls seems like a great compromise if automatic tail calls are too risky. I'd love to have them in the language. Here are some strawman syntax examples from the Syntactic Tail Calls proposal. Return Continue function factorial(n, acc = 1) { if (n === 1) { return acc; } return continue factorial(n - 1, acc * n) } let factorial = (n, acc = 1) => continue n == 1 ? acc : factorial(n - 1, acc * n); // or, if continue is an expression form: let factorial = (n, acc = 1) => n == 1 ? acc : continue factorial(n - 1, acc * n); Function sigil // # sigil, though it's already 'claimed' by private state. #function() { /* all calls in tail position are tail calls */ } // Note that it's hard to decide how to readably sigil arrow functions. // This is probably most
Read the rest
readable. () #=> expr // This is probably most in line with the non-arrow sigil. #() => expr // rec sigil similar to async functions rec function() { /* likewise */ } rec () => expr !-return function () { !return expr } // It's a little tricky to do arrow functions in this method. // Obviously, we cannot push the ! into the expression, and even // function level sigils are pretty ugly. // Since ! already has a strong meaning, it's hard to read this as // a tail recursive function, rather than an expression. !() => expr // We could do like we did for # above, but it also reads strangely: () !=> expr https://github.com/tc39/proposal-ptc-syntax#syntax-alternati...
In What happened to proper tail calls in JavaScript? (2021)
v8 did and then pulled support. JSC (javascript core) added support in June/July 2016 (a year and a half ago). Their team makes some great points about this. https://github.com/tc39/ecma262/issues/535 https://github.com/rwaldron/tc39-notes/blob/master/es7/2016-... For all of Google's talk about their syntactic tail call proposal, they haven't cared enough to implement it -- only to remove their PTC code. FF and MS are in the same position. At this point, I don't really care one way or the other, they need to quit the excuses, quit the petty power struggles, and do something one way or the other. Every year they wait is another year before we can use it. EDIT: I'd also add that the performance impact in the real world seems to be close to zero. https://github.com/tc39/proposal-ptc-syntax/issues/7
In V8 JavaScript Engine Release v6.5
https://bugs.chromium.org/p/v8/issues/detail?id=4698&q=tail%... Proper tail calls is the last ES6 feature not implemented by Chrome. Can anyone shed more light on the backstory for the hold up? I've read the challenges with debugging without a stack, but Safari's implementation of tail calls seems pretty sound and was shipped about a year ago. The last V8 blog post on the topic is almost 18 months old: https://v8project.blogspot.com/2016/04/es6-es7-and-beyond.ht... The TC39 topic they site hasn't been touched in two years: https://github.com/tc39/proposal-ptc-syntax
In V8 Release 6.3
Both TCO and PTC can decrease performance easily for a bunch of reasons. TC39 addressed this[0] when considering explicit tail call sites. Reasons vary from Windows ABI (Chakra) to something as simple as "now I have to figure out if this is really a PTC" -- and if your function has a PTC but that only gets invoked once, it's not hard to see how the extra analysis pressure doesn't weigh up to the elided stack frame. JS engines were already extremely optimized, it's not like you're taking a CS student's first lisp interpreter and adding TCO. (Fortunately, some of the litmus tests for whether you can apply PTC are encapsulated within strict mode, and the compiler stages definitely know that for free already.) [0]: https://github.com/tc39/proposal-ptc-syntax#performance
In Safari is the new IE
> The last 2 ECMA releases (2017 and 2016) have felt pretty dull honestly. It’s not exactly surprising. ES6 came out almost 6 years after ES5, so there was quite a few changes then. The yearly release cycle was always going to mean fewer features being standardised each release. While I do follow from a distance some of the work TC39 does, I can only assume that most people involved have realised that having an orderly process for feature proposals - and not trying to rush heaps of features into a single release - is a much better way to do things. > With the language moving this slow compared to faster releasing languages like Python, Elixir, and Go Python, Elixir and Go have the advantage that they have one main/reference implementation and can break backwards compatibility whenever they want (although that hasn’t gone brilliantly for P
Read the rest
ython) by just incrementing a version number. ECMAScript runtimes have to be able to run programs that were written almost two decades ago - backwards compatibility can’t be broken - and you have several major implementations (V8, Spidermonkey, etc.) to deal with. The tail call feature from ES6 is already being revisited because it caused problems [0]. > I wonder if Node.js will start to see a decline in hype since the language hasn't improved much in the last 2 years. Tools like Babel mean that people who really want to use new or experimental language features can do so. There are dozens of language features in the proposals pipeline [1] and many (if not a majority) can be used via a compiler like Babel or via a polyfill. Node.js also has the advantages of having it’s own 'standard library’ and an enormous package ecosystem to use. I think it will be fine. [0] https://github.com/tc39/proposal-ptc-syntax [1] https://github.com/tc39/proposals
In ECMAScript 2017: the final feature set
Sorry for the inaccurate shorthand; maybe that should read that SpiderMonkey supports it. Eric Faust of SpiderMonkey is a co-champion of the proposal, and spoke against implicit PTC at the March 2016 TC39 meeting. It's hard to get much stronger in support of a proposal than being a champion, and Eric works for Mozilla. From that discussion, it also sounded like there was support from the Mozilla devtools team as well. I'm interested in getting everyone's point of view. We've been discussing pros and cons at https://github.com/tc39/proposal-ptc-syntax/issues and https://github.com/tc39/ecma262/issues/535 , and it'd be great to have your input, including the overturning-prior-consensus issues you raised in committee and anything else that comes to mind. EDIT: How do you like the new wording "For these reasons, the V8 team strongly support d
Read the rest
enoting proper tail calls by special syntax. There is a pending TC39 proposal called syntactic tail calls to specify this behavior, co-championed by committee members from Mozilla and Microsoft." ?
In ES6, ES7, and beyond

Showing the 15 most recent of 17 sources. Enable JavaScript to search and browse every indexed mention.

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.