"Harmony is a super-set of ES5 strict"

Brendan Eich brendan at mozilla.com
Fri Feb 25 13:26:16 PST 2011


On Feb 25, 2011, at 1:12 PM, Boris Zbarsky wrote:

> On 2/25/11 4:08 PM, David Bruant wrote:
>> I would tend to be more in favor of disallowing Harmony features in
>> non-strict code (without explicit "use strict" directive) to avoid
>> surprises (I'm nuancing below).
> 
> I was under the impression that Harmony features would only be allowed for scripts that opt in to them (via the type or language of the <script> tag or whatnot).  Does that alleviate this concern?

Yes, Harmony requires opt-in versioning, at least via <script type="application/ecmascript;version=6"> (for example). An in-language "use version 6" pragma has been discussed too, for fail-fast when code gets copied and pasted into the wrong container.

However, some cats are (at least partly) out of the bag in Firefox: let, const, yield. Both let and yield require different opt-in already (type="application/javascript;version=1.7").

Our let and const (especially) implementations are not Harmonious, and we still need to pin down precise semantics for Harmony, but they are close enough -- see Waldemar's post: http://www.mail-archive.com/es-discuss@mozilla.org/msg05017.html -- and generally used correctly (in future-proof ways) by their fans.

We at Mozilla will bear the cost of shifting (mostly Firefox add-on) JS hackers over across any changes that do break let-, const-, and yield-using code. IOW, we renounce any potential de-facto standard in our let and const prototype implementations. We will break ourselves, and first, so that other implemntors don't have to reverse-engineer our prototypes (not that this is a credible problem: cross-browser JS code cannot use 'let' at all, and 'const' is not consistently implemented either).

The function-in-block semantics in Firefox are un-Harmonious enough that we ban those in Firefox 4's strict mode implementation.

Anyone writing cross-browser code will want to opt into Harmony, to shield downrev browsers from syntax errors.

/be


More information about the es-discuss mailing list