Comparative study of knockout.js and backbone.js

Right now, there are many client side frameworks available in industry.  knockout.js and backbone.js are two of the frameworks which have made some real good space in the market.

For Client-side developers, it is a very common question nowadays: “when to use knockout and when to use backbone?”  The answer of this question resides in two very popular patterns MVVM and MVC. Basically, MVVM is derived from MVC itself.

MVVM allows us to create View-specific subsets of a Model which can contain state and logic information, avoiding the need to expose the entire Model to a View. In MVC, our View has direct access to Model, but that is not the end. MVC provides some other benefits like better code structure. In MVVM bindings get mixed with UI markup but this is not the case with MVC. This paragraph just unveils a small discussion point between these two patterns though.

Knockout.js framework provides MVVM based development on client-side. The key features provided are declarative binding, automatic UI refresh, dependency tracking and templating. backbone.js framework provides MVC support to applications. It gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions and views with declarative event handling.

Some of the important points for knockout.js and backbone.js are as follows:

  • Both of the libraries are designed with different goals in mind.
  • If data binding and two way communication are your main concerns, knockout.js is definitely the way to go.
  • backbone.js excels with its ease of integration with RESTful services
  • knockout.js 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. Knockout does however attempt to assist with this problem.
  • backbone.js has a solid routing solution built-in, whilst knockout.js offers no routing options out of the box.
  • In knockout, data-bindings are declarative and nice to work with, but can be harder to debug than imperative code where we simply set breakpoints
  • To conclude, knockout.js seems more suitable for simpler client-side UI development whilst backbone’s feature set really shines when building anything non-trivial. That said, many developers have used both frameworks to write applications of varying complexity and it is recommended to use both at a smaller scale before making a decision on which might work best for your project.

There are many more technical points to be discussed. In our previous posts we have discussed about knockout.js features. Our next post will provide you a quick go through backbone.js framework features.

One thought on “Comparative study of knockout.js and backbone.js

Leave a Reply

Your email address will not be published. Required fields are marked *

× four = 20

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>