brendan at mozilla.com
Sat Jun 4 15:23:06 PDT 2011
On Jun 4, 2011, at 3:00 PM, Peter Michaux wrote:
> On Sat, Jun 4, 2011 at 9:52 AM, Juan Ignacio Dopazo
> <dopazo.juan at gmail.com> wrote:
>> Both styles are equally useful. Prototype based code has its own advantages
>> such as being able to easily modify the behavior of multiple objects on the
>> fly (very useful when working with 3rd party code for instance).
> Yes but this is a limitation of our tools. If Firebug let you into a
> closure and edit the code inside the closure, for example, you could
> have this ability with the closure based system.
This is hard, though. It's related to the optimization challenges in joining function objects to their one expression form. See
All solvable, but hard enough that even the latest JS engines (last I checked) show slowdowns when you scale up objects as closures vs. the prototypal equivalent.
I know, it's a vicious cycle. We can't get engine implementors to optimize harder without somehow making closure costs hurt, but since closure costs hurt developers first and engine implementors second or third, while prototypes hurt less, many developers choose prototypes. JS has prototypes as well as closures, and prototypes allow explicit sharing of "methods". This ship sailed long ago.
Good to see class syntax supporting both styles, in any event.
More information about the es-discuss