>> Object.extend(src, dest)

>This is certainly closest to paving the cowpath. Either via a built-in module 
>exporting 'extend', or as you suggest, directly on Object. The Object.extend 
>route is a bit harder to analyze, but not fatally so for any capable static 
>analysis framework.
> Either way (built-in module or Object.extend), old script (Hi Luke! ;-) could 
> use it too.

Agreed - this was my initial reaction to <| as well, and I still see a number 
of reasons to prefer a library solution over a syntax solution for both 
'Obect.extend' and 'Object.make'.

The arguments for <| as an operator seemed to boil down to:
1) It's more 'declarative'
2) It can be optimized by engines

For developer-facing benefit, I think the declarative claim is maybe not really 
very significant.  From feedback I've heard when showing <| to JS developers, I 
don't see there being a preference for <| over Object.make(proto, members).  
And as mentioned, for engine optimization, the library approach is harder, but 
should not be impossible to optimize for modern engines.  There is a chicken 
and egg game for optimization that engines likely won't invest in this till 
users use it, and vice versa - but from discussions with Chakra developers, I 
expect we'd prefer to spend our energy investing in this class of optimization 
instead of implementing bespoke syntax and hoping that developers use it.

The arguments in favor of a library alternative are:
1) Immediately useful to all JS developers
2) Simple, understandable syntax consistent with existing practice

Developers would not need to opt in to breaking changes to use the new library, 
and would not need to wait for all engine implementers to implement and all 
users to upgrade.  From discussions with some Microsoft dev teams, that could 
be a 3+ year difference in adoption timeline.  The most common usages of these 
libraries could be offered (with worse performance) by a shim library, which 
also helps.  I also generally feel like avoiding new operators when possible is 
a "good thing" for learnability and readability of the language.

es-discuss mailing list

Reply via email to