The 1JS experiment has failed. Let's return to plan A.

# Mark S. Miller (13 years ago)

thanks for accumulating this data!

Between

  • this data,
  • Apple's decision as recorded at bugs.webkit.org/show_bug.cgi?id=27226#c4,
  • the new function syntax micro-modes,
  • and the "let" issues already discussed, I reiterate that we should stop trying to twist the language to somehow shoehorn ES6 features into non-strict mode.

For both "function" and "let", when we first discussed trying to retrofit sense into ES6 non-strict mode, we knew that this was speculative, because non-strict mode cannot include web-breaking incompatible changes. This experiment has failed, so we should now return to plan A. Any ES6 features that don't fit into non-strict mode without contortion, including "let" and nested "function", should be available only in strict mode. For new function syntax, if shoe-horning it into non-strict mode requires micro-modes as previously discussed, then we shouldn't. Whatever the complaints about living with one mode distinction, we're certainly not addressing these complaints by introducing more mode distinctions.

# Rick Waldron (13 years ago)

On Wednesday, December 26, 2012, Mark S. Miller wrote:

Hi Brian, thanks for accumulating this data!

Between

  • this data,
  • Apple's decision as recorded at bugs.webkit.org/show_bug.cgi?id=27226#c4,
  • the new function syntax micro-modes,
  • and the "let" issues already discussed, I reiterate that we should stop trying to twist the language to somehow shoehorn ES6 features into non-strict mode.

For both "function" and "let", when we first discussed trying to retrofit sense into ES6 non-strict mode, we knew that this was speculative, because non-strict mode cannot include web-breaking incompatible changes. This experiment has failed, so we should now return to plan A. Any ES6 features that don't fit into non-strict mode without contortion, including "let" and nested "function", should be available only in strict mode. For new function syntax, if shoe-horning it into non-strict mode requires micro-modes as previously discussed, then we shouldn't. Whatever the complaints about living with one mode distinction, we're certainly not addressing these complaints by introducing more mode distinctions.

Proclaiming 1JS has failed just because we've learned that block scoped function declarations (arguably an awful and unnecessary idea) is counter-productive rhetoric. 1JS is more important than this "feature" and like typeof null === "null", I'd rather abandon the one feature for the greater good.

# David Herman (13 years ago)

Well, before I start arguing with you, I'd like to know what argument you're making. ;-)

Are you saying we should go back to having a MIME-type (and/or pragma) opt-in? Your subject line suggests that. Or are you saying we should simply not support some of the new features in non-strict code? Because your points only seem to be arguing for the latter, not the former.

I think the MIME type idea, while obviously attractive for our purposes, would've had terrible consequences for programmers, and I really hope we don't have to relitigate that debate.

# Mark S. Miller (13 years ago)

I cited four "features". Blocked scoped functions are simply the straw that makes the condition of the camel's back more obvious.

As for the greater good, we're all working for that. We just differ on which path leads there.

# Mark S. Miller (13 years ago)

On Wed, Dec 26, 2012 at 2:27 PM, David Herman <dherman at mozilla.com> wrote:

Well, before I start arguing with you, I'd like to know what argument you're making. ;-)

Are you saying we should go back to having a MIME-type (and/or pragma) opt-in? Your subject line suggests that. Or are you saying we should simply not support some of the new features in non-strict code? Because your points only seem to be arguing for the latter, not the former.

Sorry, I'd completely forgotten about those earlier options. I am arguing only the latter. Specifically "Any ES6 features that don't fit into non-strict mode without contortion, including "let" and nested "function", should be available only in strict mode."

# Brendan Eich (13 years ago)

Mark, you cite some issues we need to work through, but opt-in via pragma syntax beyond "use strict" is not one of them.

What's more, the big-picture claim in your Subject line ("has failed" especially) is not true. In an overriding sense, 1JS can't fail, because versioning is an anti-pattern (or at best retrospective, not prescriptive) on the web. To be more precise, ES6 will fail if it requires opt-in versioning apart from the new syntax itself. This applies to "use strict" too, since it has costs (both performance and semantic changes that double testing while old browsers are in the field).

Now, on the specific JSC bug you cite, bugs.webkit.org/show_bug.cgi?id=27226. This is actually from 2009, filed based on a misunderstanding of ES3 and not on any real-world web content, and finally marked invalid in February. It is old news. The comments from February do not prove that "[t]he 1JS experiment has failed". And JSC design decisions are not authoritative over TC39 as a whole -- rather, the reverse!.

Anyway, we can certainly make function-in-block ES6 semantics require "use strict" opt-in, but that will both diminish the use-frequency of function-in-block with sane and standard semantics, and as Andy Wingo pointed out in the JSC bug, confuse users with two semantics for the same syntax.

More in reply to Brian Terlson's thread.

# Rick Waldron (13 years ago)

On Wednesday, December 26, 2012, Mark S. Miller wrote:

Hi Rick, I cited four "features".

Unless I misread, 2 of them both concerned block scoped functions and I assumed you were referring to the let[0]=1; which was discussed and consensus on further research towards Luke's resolution was agreed to at the last meeting. I'm actually not sure what new function syntax micro-modes you're referring to, can you clarify?

# Mark S. Miller (13 years ago)

On Wed, Dec 26, 2012 at 2:58 PM, Brendan Eich <brendan at mozilla.com> wrote:

Mark, you cite some issues we need to work through, but opt-in via pragma syntax beyond "use strict" is not one of them.

Sorry for the confusion. As I just clarified in my response to Dave, I am not suggesting any of those previous MIME type or additional pragma ideas. I am just suggesting that we stop twisting the language to try to fit ES6 features into non-strict mode when these don't fit well.

What's more, the big-picture claim in your Subject line ("has failed" especially) is not true. In an overriding sense, 1JS can't fail, because versioning is an anti-pattern (or at best retrospective, not prescriptive) on the web. To be more precise, ES6 will fail if it requires opt-in versioning apart from the new syntax itself.

I am not suggesting any new opt-in beyond what we've already got. I am suggesting that we use that opt-in, rather than contort the language for the sake of non-strict mode. We all know that the non-strict mode of JavaScript can never grow into a decent language. As you've long said about the arguments object, let's stop polishing this turd.

This applies to "use strict" too, since it has costs (both performance and semantic changes that double testing while old browsers are in the field).

I thought we'd settled the performance issue. I'm surprised you're still raising it.

The purpose of testing is to alert you to places in your code where bugs may reside. Even if you never plan to run your code in strict mode, you should still test in strict mode, since anything that fails in strict mode is likely enough a bug in your code that you should investigate.

Now, on the specific JSC bug you cite, bugs.webkit.org/show_bug.cgi?id=27226. This is actually from 2009, filed based on a misunderstanding of ES3 and not on any real-world web content, and finally marked invalid in February. It is old news. The comments from February do not prove that "[t]he 1JS experiment has failed".

I was unaware of the history, thanks. I withdraw that bullet point. I acknowledge that my case is substantially weaker without it.

And JSC design decisions are not authoritative over TC39 as a whole -- rather, the reverse!.

We all know that this issue isn't so unidirectional. If TC39 mandates something and the browser makers decide to do something else, we all have a problem. The pressure to avoid these problems cuts both ways.

Anyway, we can certainly make function-in-block ES6 semantics require "use strict" opt-in, but that will both diminish the use-frequency of function-in-block with sane and standard semantics,

Since only strict mode provides sane and standard semantics anyway... ;)

and as Andy Wingo pointed out in the JSC bug, confuse users with two semantics for the same syntax.

We've already got that. To avoid confusion, "use strict".

# Brendan Eich (13 years ago)

Mark S. Miller wrote:

On Wed, Dec 26, 2012 at 2:58 PM, Brendan Eich<brendan at mozilla.com> wrote:

Mark, you cite some issues we need to work through, but opt-in via pragma syntax beyond "use strict" is not one of them.

Sorry for the confusion. As I just clarified in my response to Dave, I am not suggesting any of those previous MIME type or additional pragma ideas. I am just suggesting that we stop twisting the language to try to fit ES6 features into non-strict mode when these don't fit well.

Your subject was a declarative sentence, past tense, not a suggestion! It also meant other than what you clarified.

Ok, I don't mean to vent -- moving right along:

What's more, the big-picture claim in your Subject line ("has failed" especially) is not true. In an overriding sense, 1JS can't fail, because versioning is an anti-pattern (or at best retrospective, not prescriptive) on the web. To be more precise, ES6 will fail if it requires opt-in versioning apart from the new syntax itself.

I am not suggesting any new opt-in beyond what we've already got. I am suggesting that we use that opt-in, rather than contort the language for the sake of non-strict mode. We all know that the non-strict mode of JavaScript can never grow into a decent language. As you've long said about the arguments object, let's stop polishing this turd.

But it's not the same turd. Rest parameters combined with destructuring and default parameters can do more than arguments could do, and crucially do so via new syntax. There's no comparison to function in block, which syntax already exists in the de-facto standard, whose meaning ES6 proposes to change.

Let's move away from feces metaphors :-|.

The major issue I see outstanding between us is that the economics of strict mode as faced by most developers must be considered, on top of the desirability of the feature that doesn't fit in sloppy mode.

This is a human factors problem in part. We should do quantitative studies. I just asked in re: Brian's head post whether his crawl checked for "use strict" usage. Another thing we could try: for the 4% of scripts used by the 2235 sites crawled that use funciton-in-block, how many can "use strict" without any revision?

The economics of strict mode is subject to pedagogy, better optimizations for strict code over time, and the death of pre-ES5-strict browsers over time, too. So again I'm not beating up on strict mode. But I do think we must look at the thing in the field, including its human factors, and not just say "use strict" always, be happy. It's not always an option in large projects or even small ones using libraries that aren't strict-ready. More below.

This applies to "use strict" too, since it has costs (both performance and semantic changes that double testing while old browsers are in the field).

I thought we'd settled the performance issue. I'm surprised you're still raising it.

It's not quite superstition. Look at the strict vs. non-strict differences in the charts for these three:

jsperf.com/calling-into-strict, jsperf.com/use-strict-vs-array/2, jsperf.com/use-strict-vs-array/3

In theory, apart from freakish cases involving arguments objects and parameter aliasing, strict mode should not be a performance penalty and could even help. In practice we aren't there yet -- and developers know this.

The purpose of testing is to alert you to places in your code where bugs may reside. Even if you never plan to run your code in strict mode, you should still test in strict mode, since anything that fails in strict mode is likely enough a bug in your code that you should investigate.

You don't need to tell me!

The problems is the added burden and the inevitable failure of real developers to take it on with the same diligence they use on one-mode JS -- which may be less diligence than you would like, but hold that equal! The testing burden has gone up.

I'm describing, not prescribing. Old pre-strict browsers will die off, we'll be in a better place. I like strict mode in general and won't quibble about a few corners here. But the problem isn't my opinion of it or yours. The problem is that strict mode has meant more to go wrong, more to test, and some performance faults.

Now, on the specific JSC bug you cite, bugs.webkit.org/show_bug.cgi?id=27226. This is actually from 2009, filed based on a misunderstanding of ES3 and not on any real-world web content, and finally marked invalid in February. It is old news. The comments from February do not prove that "[t]he 1JS experiment has failed".

I was unaware of the history, thanks. I withdraw that bullet point. I acknowledge that my case is substantially weaker without it.

Ok, thanks.

And JSC design decisions are not authoritative over TC39 as a whole -- rather, the reverse!.

We all know that this issue isn't so unidirectional. If TC39 mandates something and the browser makers decide to do something else, we all have a problem. The pressure to avoid these problems cuts both ways.

And how! We've already heard some feedback on temporal dead zones from one TC39 implementor-rep at the September meeting. I never said implementor feedback doesn't count, though. Only that the authority-arrow runs the other way from what your bullet point suggested.

It's pure mischief for implementors to "vote" outside of TC39 by making random deviations from draft-ES6 on purpose and then asserting precedent or authority.

I know you didn't endorse that but your citing this bug under the inflammatory subject was going in that direction.

Anyway, we can certainly make function-in-block ES6 semantics require "use strict" opt-in, but that will both diminish the use-frequency of function-in-block with sane and standard semantics,

Since only strict mode provides sane and standard semantics anyway... ;)

and as Andy Wingo pointed out in the JSC bug, confuse users with two semantics for the same syntax.

We've already got that. To avoid confusion, "use strict".

That's a prospective, prescriptive, pedagogical approach. It will help over time, but right now, not so much. Real developers face real code, most of it non-strict. They can't always afford to make it all strict. They therefore face the confusing schism in function-in-block semantics that Andy cited.

# Brandon Benvie (13 years ago)

As an aside, ES itself can't self-host its own builtins in strict mode because of the (two of the very few) semantic differences that exist between strict mode and non-strict mode: non-strict thrower properties (which I've come to consider an annoying blight that punishes developers in order to influence implementers) and strict this-mode differences. Every semantic difference you mandate furthers this gap.

# Brandon Benvie (13 years ago)

Er I meant ThrowTypeError.

# Axel Rauschmayer (13 years ago)

As an aside, ES itself can't self-host its own builtins in strict mode because of the (two of the very few) semantic differences that exist between strict mode and non-strict mode: non-strict thrower properties (which I've come to consider an annoying blight that punishes developers in order to influence implementers) and strict this-mode differences. Every semantic difference you mandate furthers this gap.

I understand that throwing exceptions (that wouldn’t be thrown in sloppy mode) is a problem. But why is this? How would this not pointing to the global object inside a strict-mode builtin be observable to the outside?

# David Bruant (13 years ago)

Le 27/12/2012 02:52, Brandon Benvie a écrit :

As an aside, ES itself can't self-host its own builtins in strict mode because of the (two of the very few) semantic differences that exist between strict mode and non-strict mode: non-strict thrower properties (which I've come to consider an annoying blight that punishes developers in order to influence implementers) and strict this-mode differences. Every semantic difference you mandate furthers this gap.

I fail to understand why built-ins can't be implemented in strict mode. Can you provide a concrete example of something that can't?

Thanks,

# Brandon Benvie (13 years ago)

I ave to recant on this after having doing some research (and actually making it work). The original reason about ThisMode may still be true but I'm less sure. It was basically about being unable to identify the correct global this in strict mode since its not automatically provided for you, and multiple global is now a common thing in es6, but I don't think this ended up gmpering anything in actual usage.

The other reason was because of ThrowTypeError, which requires a.) adding multiple accessor own properties to every function object, and b.) modified GetOwnProperty semantics. Upon inspection, I couldn't actually find anything in the spec that prohibits builtin functions from having those ThrowTypeError accessors like I had originally supposed there was. In my implementation I cheat and use magic to remove them even though the functions are compiled as strict (they're in implicit module bodies) but I now realize that's not necessary, at least to be spec compliant.

# Brandon Benvie (13 years ago)

To elaborate on the ThisMode scenario, take the following example (also available at gist.github.com/4401538):

var value = 10;

module X {
  // implicit "use strict"
  var value = 20;

  export class Builtin {
    constructor(){
      if (this == null) {
        // what global am I?
      }
    }

    method(){
      if (this == null) {
        // what global am I?
        return value;
      }
    }
  }
}

module Y {
  // implicit "use strict"

  var value = 30;
  var global = this;
  var x = new X.Builtin;

  export function getValue(){
    return x.method.call(null);
  }
}


console.log(Y.getValue());

I'm fairly sure in a userland code scenario the result should be 20. My concern was whether any code in the ES6 stdlib is this sensitive in such a way that either value should be either 10 or 30. I haven't identified any in which it should be, but I'm not confident none such example exists.