excluding features from sloppy mode

David Bruant bruant.d at gmail.com
Thu Dec 27 02:36:23 PST 2012

Le 27/12/2012 06:32, Brendan Eich a écrit :
> Mark S. Miller wrote:
>> Superstition aside, and once pre-ES5 browsers are not significant, the
>> only purpose of sloppy mode is for old code that must be kept running
>> without active maintenance.
> That is a teleological statement -- you're talking about purpose, 
> designed intent, goal, "The Good (Life)".
> Very philosophical, I dig it ;-). However, in reality as Dave said in 
> a recent message, the Law of Least Effort says people will forget to 
> write "use strict"; and we'll have sloppy mode code till the cows come 
> home.
The Law of Least Effort also brought us compile-to-JS languages. 
Coffeescript still doesn't compile with "use strict"; by default [1], 
but it seems open to it when all non-strict browsers will have died and 
the perf issues are solved.
In the future, I expect:
* more usage of compile-to-JS languages
* all compile-to-JS languages to compile to strict mode by default

Interestingly, this would turn the result of the Law of Least Effort 
from "some will forget" to "people won't forget".
Of course people will probably always write handwritten JS and some will 
forget to put "use strict";, but I feel new non-strict code will 
eventually become a rare exception asymptotically leading to, but never 
reaching inexistence.

>>   For any code being actively maintained, it
>> should move into strict mode.
> Very hortatory, but the kids are alright and they don't all follow a 
> single "should". Between dissenters and LoLE or Law of Murphy ;-), I 
> bet your "should" will become an ineffectual nag over the next few years.
> If, one fine day, virtually everyone does as in Perl and starts their 
> programs with "use strict'; (or "module {" with closing "} after), I 
> will raise a toast to you and others who helped teach that practice. 
> It's nowhere near a certainty, and "should" isn't "would" or "will".
I feel this will happen when compile-to-JS compile by default to strict 
mode. Only years will tell.

>>   Sloppy mode will become a relic only for code no one touches.
> Perhaps, but not on a predictable schedule and not (if I'm right) 
> within the next few years, when we want ES6 adoption -- including new 
> syntax.
I sadly agree.

> Finally, to connect to the first point, strict mode has some overhead 
> (LoLE works against it, people forget to type the directive). I know 
> developers who do not use strict mode, but who will rapidly adopt rest 
> and default parameters, destructuring in general, and other new forms. 
> This adoption of ES6 is partly subjective, distributed over time and 
> (head-)space. It should not be yoked to strict mode adoption.

> Yoking the two multiplies the likelihood of adoption to get a smaller 
> product. That's why I favor implicit strict mode only for bodies of 
> new head syntaxes, starting with module as Dave proposed.
> I'm ok wtih class opting its body into strict mode, although did we 
> decide that one way or the other? I forget.
I don't know, but I'd be in favor of implicit strict in classes. Moving 
code to module and classes would be the gradual move to strict mode Mark 
talks about.
If people notice perf issues against equivalent not-in-module/class 
code, they'll report it. Hopefully, that'll be an incentive enough for 
implementors to make strict mode at least as fast as sloppy mode.


[1] https://github.com/jashkenas/coffee-script/pull/2337

More information about the es-discuss mailing list