Thanks for the feedback, John.

I have to admit that at first I was also taken aback by the apparent
complexity of the "syntax for efficient traits" strawman. Traits have many
knobs, and require a lot of syntax to turn these knobs.

Regardless of whether you'd want nice declarative syntax for traits for the
sake of usability, for traits.js in particular, there's another important
benefit to having some language support. When using Trait.create to create
"tamper-proof" objects whose methods have an unspoofable |this|-binding, the
traits.js library creates a method wrapper per method per instance (to bind
|this| to the instance). I still need to verify how much overhead this
actually creates, but there definitely is overhead, and I don't see any way
to avoid it without some support from the language.

Cheers,
Tom

2011/10/5 John J Barton <[email protected]>

> In trying to update my JS approach I looked into 'traits'. I'm still on the
> fence about using them at this stage, but MarkM was asking for feedback of
> pretty much any kind so here is a little.
>
> I believe I understand traits for the most part just from the info on the
> Web site:
> http://traitsjs.org/
> (but read the examples in the Paper, not the one in the Tutorial).
> Traits feel like JS to me: a reusable set of methods packaged in an object.
> The Trait construct add regularity and organization to a wide-spread pattern
> of JS use, but it feels like a tool you pick up when you need it. The key
> operations are create and compose, with resolve and override to handle
> exotic issues.
>
> On the other hand I had the opposite reaction to
> http://wiki.ecmascript.org/doku.php?id=strawman:syntax_for_efficient_traits
> That proposal is a completely different language with many new keywords and
> operators.
>
> I came away deciding to stop using |prototype| + new in favor of
> Object.create() and to revisit the traits.org library after a bit.
>
> jjb
>
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to