excluding features from sloppy mode (was: the 1JS experiment has failed)

David Herman dherman at mozilla.com
Wed Dec 26 14:58:37 PST 2012

On Dec 26, 2012, at 2:30 PM, Mark S. Miller <erights at google.com> wrote:

> 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."

Then I'm with Rick: your subject line was pretty inflammatory and not actually what you were arguing. This isn't a debate about 1JS. It's a narrower debate about whether some features should be available only in strict mode. That's not something I feel as strongly about, but here's how I see it:

- Strict mode, while providing some really helpful cleanups of JS, has created introduced serious and unavoidable complexity to programmers. The split has some pretty seriously pervasive differences, in particular the different `this` binding for function calls.

- I believe the least miserable option for programmers to deal with this complexity is just to write code defensively assuming it could be used in strict contexts (e.g., by being concatenated with strict code), and to write all code as strict code. While this is a stick rather than a carrot, at least it's incentive for a good thing: i.e., using strict mode.

- On the other hand, "default is non-strict" is still a huuuuge incentive in the other direction. It's perfectly plausible that for the foreseeable future, many programmers will continue not to use strict mode. If they don't know about strict mode, or don't want to use it for whatever reason, failing to support features like `let` will lead them to use older, worse features in place of better, new ones.

- Andreas has argued before that we should treat that as a feature rather than a bug. He argues that (a) the new features will be carrots to lead people to strict mode; and (b) the incompatibilities between strict and non-strict code are far simpler in total than all the micro-inconsistencies required to shoe-horn the new features into sloppy mode. But my concerns are that for (a) we don't actually know the carrots will be visible or tasty enough for programmers (I took my crystal ball to the pawn shop years ago), and for (b) the big-but-obvious inconsistencies will be universally, unavoidably tripped over. I'm just worried it's choosing "slap the developer in the face" instead of doing the work to iron out an imperfect but less obnoxious back-porting story.

So I guess I'd like to sit back a bit and hear others' opinions about this. But let's be clear that we're only talking about excluding some new features from sloppy mode, *not* about the ES6 opt-in.


More information about the es-discuss mailing list