Backbonejs vs Angularjs
by Irfan Ali
NOTE : I am not trashing Backbone. It was a great tool earlier and in my opinion, its usefulness has diminished since the introduction of newer frameworks like Angular and Ember.
I know that people in general, still choose Backbone over Angular because it seems to be the safer choice, because you can’t find as many X-framework developers as Backbone etc etc.. I am attempting to make an argument that Angular is a better choice in all scenarios where you would use Backbone. Finding developers and how much you pay them is an organizational choice. But, my attempt here is to prove that, if you have 2 smart developers who have no knowledge of Angular and pick 4-5 developers who know Backbone for a largish project, the investment of learning Angular will pay off in the long run. Less code to write means less code to test means less code to debug means less code to maintain. It also means a lesser page-weight at the end of the day. (Had so many issues at ETS to decide the right framework)These are some of the advantages you should not ignore if you are making an objective decision.
One of the first points that people quote, when they talk about the advantages of Backbone is its compactness. Its just xKB minified and gzipped. Lets see some stats, shall we?.
Angular ( 1.0.3 ) is 77KB minified. If you include Angular ( just that one file )it WILL work on its own.. It does not depend on anything.. If you include JQuerybefore Angular, then angular will start using JQuery for DOM manipulation. But, including JQuery is upto you. You dont necessarily have to.
Backbone by itself is around 18KB minified (link). Now add in its dependencies Underscore ( 13.6KB minified – link ) and then we have JQuery ( 93KB minified) / Zepto ( 25KB minified ) itself ( You cant use Backbone on the client side without one of these! )
To note here, Backbone has a much stronger dependency on JQuery than Angular. Some people might complain that even Angular can use JQuery or people generally tend to include JQuery along with Angular in projects etc etc.. People do, but its not absolutely necessary. A Front End project with Angular can make do without JQuery.
Here is what you get, when you decide to write an application with Backbone as your framework. 5 Classes. Model, View, Events, Collection and Router. And Backbone.Sync ( but lets leave it out for now ) . Mainly, this is what constitutes Backbone itself. That’s it. These are all Base Classes. When you want any of these functionalities you extend these classes and make use of them.