News for hackers. Stuff that matters.
Re:Backbone vs. Simple JavaScript Inheritance by spicyj on Saturday June 01, 2013 @06:01PM (#5806189)
I don't understand how the code snippets are at all equivalent. It looks like ResigsClass doesn't extend anything except Class itself whereas myModel extends Backbone.Model which presumably starts off more complicated.
Re:Backbone vs. Simple JavaScript Inheritance by just2n on Saturday June 01, 2013 @06:32PM (#5806324)
Yes. This is precisely the problem. The inheritance model used by Backbone will be significantly more performant in terms of method calls, in general, because it doesn't implement a `super` concept. The construction should also favor Backbone's model since it doesn't create the function wrappers (in the non-trivial case, anyway).

Look at what Backbone's `extend` does: https://github.com/documentcloud/backbone/blob/master/backbo...

The subclass's constructor calls the parent's constructor function, just as in Resig's, however Resig's `Class` is:

    this.Class = function(){};
Whereas `Backbone.Model` looks like this: https://github.com/documentcloud/backbone/blob/master/backbo...

It's not hard to predict the outcome of this "benchmark."