Search code examples
javascriptweb-applicationsbackbone.jsframeworksknockout.js

Angular.js Backbone.js and other MV* patterned js libraries?


I am quite newbie to web application, and more specifically to this MV*pattern. We are making a web application and we thinking of departing from jQuery, not completely, but we are trying to implement a client side language with MVC, MVVM, or MVP support. Basically something that separates views from model. Being new to this MV* pattern I stumbled upon this site.

It basically list (almost!) all client side language/framework that support this MV* pattern, and after visiting it I am really confused. Because according to this site..

At the end of the day, Ember.js is the only framework which has everything I desire. I recently ported a relatively small Backbone.js application over to Ember.js and, despite some small performance issues, I am much happier with the resulting code base. Being championed by Yehuda Katz, the community around Ember.js is also amazing. This is definitely the framework to watch out for.

But on SO, I found this, and it makes me think that angular is much better, while on SO again, this, and this which makes me think it might be backbone what I am looking for.

To make the matter worse, the tests show totally different result. Here

http://jsfiddle.net/HusVw/1/ Backbone clear winner

http://jsfiddle.net/ericf/NrpcQ/ Backbone winner again

http://jsperf.com/angular-vs-knockout-vs-extjs-vs-backbone/2 angular winner for less data for more its knockout

http://jsperf.com/knockout-js-vs-direct-dom-manipulation/3 Backbone again

http://jsperf.com/angular-vs-knockout-vs-ember/33 no way its ember as the site mentioned

So, basically this all is totally confusing me, I can't decide what in web's name I should learn, and what should I implement in the site. As in tests Backbone clearly stands out, but I've heard a lot about knockout, but the SO links I mentioned say about angular? I know it might be dependent on the application I am currently developing, but I want a broader view, what would be useful not only for this project, but for a longer term? In which case you'd prefer which framework? Or Should I just learn them all?(jk, can't really do that in a plausible time.)

To make things more f**** up, I heard about dart, and wiki says..

The goal of Dart is "ultimately to replace JavaScript as the lingua franca of web development on the open web platform."

So if js is going to be replaced, why the hack I am even considering learning these js libraries/framework(s)?

So, basically, its all messed up and I am totally confused? Can any one please help me decide?


Solution

  • There is probably no objective answer, but here's my 2 cents:

    Backbone usually leads to much larger code bases that are more difficult to maintain. Similar to the anecdote in your links, I've worked on one project where the code shrank from 2500 lines with Backbone to 600 lines with Angular. Knockout probably would have yielded equally small (=good) results. My colleagues have moved away from Backbone to Knockout and were much happier afterwards.

    The advantage of Backbone is that it is really lightweight and gives you more options to structure things. That also means you can do more performance tuning, so it can be faster. Those very same aspects are also its disadvantage: You need to structure things yourself which means: more code, more complicated and potentially more bugs.

    Regarding the tests you mention: They are hardly objective, since they emphasize one very particular use case. Also, they were posted by the author of Backbone himself, so obviously they show Backbone in a good light. For normal UIs, performance should not be a problem no matter which of the 3 (Backbone, Angular, Knockout) you choose. One caveat for Angular: If you want to dynamically display more than 2000 elements on your page, it could be problematic (see the answer of Angular's creator himself here: How does data binding work in AngularJS?).

    About Dart: Its goal is to be a language, not just a MV* framework within a language. That is a completely different beast and if you simply need a MV* framework, Dart would be overkill. Also, Dart is still very young and not natively supported in most browsers.