Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



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."




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: