In the first part of this article we talked about the questions you need to ask before choosing a JavaScript framework. Once we have decided on the need for a framework, we saw how aspects like features of the framework, difficulty-level in learning, external dependencies and the level of community support guide our choice.
In this second and concluding part we are going to compare the three most popular JS frameworks namely AngularJS, Backbone.js and Ember.js.
The 5 parameters on which we will evaluate the three frameworks include:
A quick glimpse into each of the three frameworks and what they do:
Table of Contents
Who: Developed by Google; used internally by them and MIT licensed.
What: Angular follows the MVC pattern of software engineering and encourages loose coupling between presentation, data, and logic components. Using dependency injection, Angular brings traditional server-side services, such as view-dependent controllers, to client-side web applications.
Who: Developed by Jeremy Ashkenas, (creator of CoffeeScript and Underscore.js ) and DocumentCloud. MIT licensed.
What: JavaScript framework with a RESTful JSON interface and is based on the model–view–presenter (MVP) application design paradigm. It gives structure to web applications by pulling your model out of your DOM and into Backbone’s Model, Collection, and View objects.
Who: Developed by Yehuda Katz (a member of the jQuery, Ruby on Rails and SproutCore core teams) and Tom Dale. MIT licensed.
What: Based on the model-view-controller (MVC) software architectural pattern, it allows developers to create scalable single-page applications by incorporating common idioms and best practices into a framework. Provides a rich object model, declarative two-way data binding, computed properties, automatically-updating templates powered by Handlebars.js, and a router for managing application state.
Let us now see how these three frameworks compare against one another.
Size of the framework is an important parameter because it adds to the overall size of your application. This is especially important if you are building mobile apps.
The Gzipped size (no dependencies) of Angular, Backbone and Ember are 36kb (approx), 6.5kb and 90kb respectively.
However, both Backbone and Ember have external dependencies.
Backbone’s hard dependency is on Underscore.js ( >= 1.5.0). For RESTful persistence, history support via Backbone.Router and DOM manipulation with Backbone.View, jQuery is required and for older Internet Explorer support json2.js is required.
Ember needs jQuery and Handlebars.
Angular does not have any external dependencies.
The size of the framework affects performance. The trade-off is usually between features and flexibility. The more ambitious and feature- rich a framework is, more is the size and also more difficult it will be to integrate it with others particularly on the same page of an app. The more flexible the framework, less is the size but will require developers to write a lot of code.
Angular is very easy to start with. You can do some awesome things like two-way bindings and out-of-the-box directives and filters just by learning the basics. From there, the learning curve becomes steep. Even the documentation uses many Angular specific jargon.
Backbone is the least opinionated of the three frameworks and its basics are therefore very easy to learn. However, the flipside to this is there are no ways to know how to best structure your code. It has fewer conventions than the other frameworks- it does not default to any view template, does not have a default project structure and no in-built testing recipe. It requires the developer to make a lot more decisions.
Ember has the steepest learning curve out of the three and requires some learning to get started even on the basic things. It is opinionated about how certain things should be done including how you name your objects and how you organize your files.
AngularJS may be difficult to learn and may require you to structure your code in a particular way but once you get the hang of things, you can be very productive with it.
The key feature of Backbone is flexibility as it is the one with the least conventions and opinions. However, due to its inherent flexibility it requires you to write a lot of boilerplate code which goes against developer productivity.
Ember believes in conventions over configuration but all you need to do is learn and apply these conventions and then watch Ember do things magically. For example as mentioned in the above point, Ember can get lot of things done for you if you follow its naming conventions. If you have a url route /stories in the app, then you will have:
To gauge the community support and popularity for these three frameworks we looked at data from GitHub, Stack Overflow and Twitter and plotted the level of community support based on parameters like:
All time contributors help to understand the governance style of project―whether it is managed by a small group of people or open to contributions from diverse audience. Angular is a clear winner here. However, you should not overlook the fact that Angular is the oldest (initial release 2009) of the three frameworks and Ember (initial release 2011) is the youngest. Backbone.js initial release was in 2010.
Angular and Ember seem to be getting some shared love while Backbone lags behind in terms of commits.
Pull requests let you know how many changes (additions, deletions, modifications, etc.) the GitHub community has suggested for a specific framework. Once a pull request is sent, interested parties can review the set of changes, discuss potential modifications, and even push follow-up commits, if necessary. Anyone with push access to the repository can complete the merging of the pull request.
This helps to understand how much of the community’s contributions are being integrated into the project’s codebase. The higher the percentage of merged pull request, more is the framework open to community contributions.
The number of tagged questions on Stack Overflow is also an indication of how active a framework’s community is. Angular is a clear winner here.
[For details of Stack Overflow data on Angular, Backbone and Ember]
All three frameworks boast of some big names in their client list.
Google, YouTube on PS3, Nike, Huffington Post and many more use AngularJS. [Related read: Built with AngularJS]
Twitter, Foursquare, LinkedIn Mobile, Soundcloud, etc. use Backbone.js. [Related read: Projects and Companies using Backbone]
Yahoo, Groupon, Zendesk, Square and many more use Ember.js to power their apps. [Related read: See who’s using Ember.js]
Each JavaScript framework has its unique set of advantages and disadvantages and it would be unfair to say that one is better than the other. They all have a similar goal-to make the process of application development faster. The choice of the right framework depends to a large extent on the kind of application you are trying to build and your personal preferences as a developer.
Based on our experience, we would however suggest the following:
Now over to you. Which framework did you choose for building your application and why? Share your thoughts and lessons in the comment section below.
Ever had a data set that seemed more complicated than a Rubik's cube? You’re not…
We’ve all seen them in textbooks or presentations—those overlapping circles that simplify complex information into…
We’re excited to announce the upcoming release of FusionCharts v4.1—a groundbreaking step forward in the…
Have you ever been overwhelmed by a massive data set and wondered, "How do I…
If you’ve ever tried to make sense of the stock market, you’ve probably come across…
Imagine you’re comparing the sales performance of your top product lines across different regions, or…
View Comments
Check this out for a crowdsourced comparison of angularjs vs backbone https://www.pearstopears.com/#!/comparison/15
Does the author have any thoughts on Angular 2.0? It was announced in October at the ng-europe conference that v2.0 will radically differ from v1.0 and amounts to a complete redesign. Details here: https://www.infoq.com/news/2014/10/angular-2-atscript
Unfortunately, as the release of v2 is a year away, this makes it impossible to consider developing a long-life project in Angular v1 as upgrading to v2 will amount to a large project in itself, with no upgrade path on offer.