ES6 modules (sorry...)

C. Scott Ananian ecmascript at
Mon Jun 16 10:41:18 PDT 2014

On Mon, Jun 16, 2014 at 1:06 PM, Domenic Denicola
<domenic at> wrote:
> From: es-discuss <es-discuss-bounces at> on behalf of C. Scott Ananian <ecmascript at>
>> Using destructuring syntax for imports would be a *good thing*.  It builds on our existing understanding of JS constructs, instead of adding more gratuitously different things to learn.
> This would be a very *bad thing*, as long as the current model---where exports are something wildly different from properties of an object, but instead are cross-file `with`-esque read-only-but-mutable bindings---was maintained. It's extremely important that these bindings look and are manipulated as differently as possible from normal declarations and destructuring of object properties.

I understand why you feel that way, but I still disagree.  Even if the
bindings are technically mutable, except for during startup in modules
with cyclic dependencies (which are thankfully very rare), most
programmers will not observe this behavior.

IMO we should optimize for the common case: treat the module import as
a destructuring binding.  *Later*, when the JS developer is more
advanced and is interested in learning about the corner cases, you can
get into the weeds with mutable bindings etc.  But don't force the
developer to learn things that we'd rather no one use in the first

That is, IMHO mutable bindings and modules with cyclic dependencies
are members of "the bad parts" of JavaScript.  Sure, sometimes there's
a valid reason to use them.  But for most developers they will be
happier sticking with "the good parts" and just thinking of modules as
objects with immutable properties.  Don't force people to learn about
the bad parts just to get work done.

More information about the es-discuss mailing list