Backbone.js Versus KnockoutJS
Understanding the subtle differences between MVC, MVP, and MVVM is important, but developers ultimately will ask whether they should consider using KnockoutJS over Backbone based in what we’ve learned. The following notes may be of help here:
Both libraries are designed with different goals in mind, and it’s often not as simple as just choosing MVC or MVVM.
If data binding and two-way communication are your main concerns, KnockoutJS is definitely the way to go. Practically any attribute or value stored in DOM nodes can be mapped to JavaScript objects with this approach.
Backbone excels with its ease of integration with RESTful services, while KnockoutJS Models are simply JavaScript objects and code needed for updating the Model must be written by the developer.
KnockoutJS has a focus on automating UI bindings, which requires significantly more verbose custom code if attempting to do this with Backbone. This isn’t a problem with Backbone itself per se, as it purposefully attempts to stay out of the UI. Knockback does, however, attempt to assist with this problem.
With KnockoutJS, we can bind our own functions to ViewModel observables, which are executed any time the observable changes. This allows us the same level of flexibility as can be found in Backbone.
Backbone has a solid routing solution built in, while KnockoutJS offers no routing options out of the box. One can, however, easily fill in this behavior if needed using Ben Alman’s BBQ plug-in or a standalone ...