Backbone vs. Simple JavaScript Inheritance
1–10 of 25 posts
Re: Backbone vs. Simple JavaScript Inheritance
#2Re: Backbone vs. Simple JavaScript Inheritance
#3Our experience was that backbone was very helpful in laying out code and providing clean event triggering, but that a lot of it was simply too slow to use. We started out with a View per card, but that was impossibly slow with 100+ cards (and we need to support ~1000+). We ended up with just one view for the Card section, and a view each for the sidebar and options sections. That made it much faster, but also took away many of the benefits of backbone.
We also ran into significant speed problems with model gets and sets. Initializing the data for 200 cards (~10 attributes per card) took hundreds of milliseconds on Chrome and other browsers. We ended up using plain javascript objects for the hottest parts of that code.
Overall to us, backbone was probably worth it, but also cost us many long days of performance debugging, and we're still not 100% happy with it. For our next project we may try something else.
Re: Backbone vs. Simple JavaScript Inheritance
#4Re: Backbone vs. Simple JavaScript Inheritance
#5[1] https://github.com/documentcloud/backbone/blob/master/backbo...
Re: Backbone vs. Simple JavaScript Inheritance
#6For our recently launched flashcards tool, we built it in Backbone. Demo: http://quizlet.com/23770911/flashcards Our experience was that backbone was very helpful in laying out code and providing clean event triggering, but that a lot of it was simply too slow to use. We started out with a View per card, but that was impossibly slow with 100+ cards (and we need to support ~1000+). We ended up with just one view for t…
Backbone's three major components, Models/Collections, Views and Events do take some planning to coordinate effectively, but that's part of laying out your application.
Also, using bare JS objects is not an anti-pattern in Backbone. Use Models/Collections when you need to manage data, Views when you need to monitor parts of the DOM, and Events to manage messages between your components. Apply as necessary.
P.S. Model.get is literally a single line of bare JS object property access: http://backbonejs.org/docs/backbone.html#section-38 but if you have a lot of events, or validations conditioned to fire on attribute changes, that may effect how long it takes your setters to run (http://backbonejs.org/docs/backbone.html#section-41 )
Re: Backbone vs. Simple JavaScript Inheritance
#7Backbone's 'extend' is portable to non-Backbone classes[1]. It would be more interesting to see the performance profile comparison of Backbone and Resig implementations of extend when used to inherit from the same class (either an empty class, or a Backbone class). [1] https://github.com/documentcloud/backbone/blob/master/backbo...
TL;DR: the Backbone approach has similar performance characteristics compared to Resig's when instantiating similar objects. In some browsers (Firefox Nightly, Safari), Backbone's approach is significantly faster. It's also compatible with strict mode — although Backbone itself doesn't use strict mode — whereas Resig's uses arguments.callee which will throw errors.
Re: Backbone vs. Simple JavaScript Inheritance
#8Re: Backbone vs. Simple JavaScript Inheritance
#9For our recently launched flashcards tool, we built it in Backbone. Demo: http://quizlet.com/23770911/flashcards Our experience was that backbone was very helpful in laying out code and providing clean event triggering, but that a lot of it was simply too slow to use. We started out with a View per card, but that was impossibly slow with 100+ cards (and we need to support ~1000+). We ended up with just one view for t…
Re: Backbone vs. Simple JavaScript Inheritance
#10I 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.
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."