1. Which frameworks that to be compared ?
The previous posts mentioned about AngularJS, EmberJS, BackboneJS and KnockoutJS. All they are well known, always appearing the top results for Google search. In this post, I will present one more candidate – CanJS, it just attracted me for couple days because of it’s very easy for understanding. Someone advise me that bring Meteor and ReactJS/Flux to the list, but it’s not fair as Meteor is complete platform which more widely than frameworks. ReactJS/Flux is just a library, along side with Flux as its architecture.
2. Which factor to be used for evaluating ?
A lot, but the popular factors are features, maturity, community, size, performance, testing, license, dependencies …
3. How do we evaluate the framework with other ones ?
“Use the force, read the source”, as analyzing on Part 2. How ever, we will dive into the features rather than statistic. Maturity should be considered by Github, Stack Overflow data, because of reflecting the powers of community supports. Size is not important much for web desktop development, but mobile web.
The challenges are now I am not expert with all candidates, except Angular, Backbone that I have experience before, but nor Ember and Knockout.
Dive into analyzing factors
- Google productions such as YouTube on PS3. Nike, Huffington Post and many more use Angular already.
- Very good documentation, examples
- API not stable, Angular team release several minor releases and hot fixes.
- Growing fast with large community support.
- Used by Bitbucket, FourSquare, USAToday, DocumentCloud …
- APIs is very stable
- A lot of example along with notation source codes.
- A lot of watcher on Github
- API only turns into stable since 1.0
- A lot of examples
- Good documentation
- Yahoo, Groupon, Zendesk, Square are using Ember for their products.
- Great documentation including jsfiddle like examples
- Stable API
- A lots of examples.
- A lots of watchers on Github
- A lot of application on production, including best well-known jsfiddle.net
Size and dependencies
|Size (Kb min + gzip)||Size (Kb min + gzip)|
Angular – http://ngmodules.org/ – 1488 modules
Backbone – http://backplug.io/ – 256 plugins
Ember – http://www.emberaddons.com/ – 1157 addons
Knockout – https://github.com/knockout/knockout/wiki/plugins – 65 plugins
Framework features is the most important factor for making decision. It provides the necessary foundation to build useful applications. Framework features can come from development team, or project requirement.
Observables: The ability to track the changes on object (Model).
- Angular does dirty checking on all bound DOM elements on the page since there are no standard get/set method. Dirty checking means developers must concern about performance that could be happen on large page.
Dynamic routing: When the url changes, framework should able to detect and act according this changing.
Knockout does not support routing as itself, but developer has several options to use routing via Sammy.js or history.js, pager.js
View bindings: The view automatically refreshes/re-renders when objects in the view change.
Two way bindings: The change automatically update in both UI/binding values when another changes its value.
Partial views: a sub-view that to be embedded in primary view, so we can reuse partial views across multiple views.
Filtered list views: the views can be filter according certain criteria.
String-based templates take string or text templates and replace the dynamic parts with data from models
DOM-based templates embrace the declarative nature of mark-up and create an html on steroids experience where html is annotated with additional attributes to describe the binding and events needed.
Angular is difficult to learn and may require developer to structure source code in a particular way. It provides dependency injection, ajax, routing, cookies, promises and much more…
Backbone is flexibility as it is the one with the least conventions and opinions. However, it may require developer to write a lot of boilerplate code which reduces developer productivity.
Ember allows developer to wrap all of repeated pieces of code inside components. Ember believes in conventions over configuration, so it can get lot of things done if we follow its naming convention.
Knockout support both DOM and Text based templating, that more flexible for developer who get familiar with one before. Knockout is targeting to data-binding mainly, so if we want to use it as full-fledged framework, we should choice anther its implementation as DurandalJS
The framework that supports modularity and dependency injection is most suitable for writing Unit test.
Modularity is that code can have small pieces that can be tested in isolation
Dependency injection is able to change dependencies in tests
Angular is the best framework for testing, with the core supports both modularity and DI, also support mocking controller and directive dependencies. The latest version supports E2E test via Protractor which launches application in a browser and interacts with it via Selenium.
There are many test frameworks and tools available to the Angular developer, brings the great flexible options.
Backbone was not built with testing capability. Developer must spend effort to create tests via third party solutions such as Jasmine, SinonJS.
Ember is designed with testing as a core part of the framework and its development cycle. Ember supports well for both integration test and unit test.
Knockout was not built for testing in mind, in which developer could spend much effort to writing test or make their code to be testable. Like Backbone, testing should be done with third party solutions.
Backbone version: http://todomvc.com/examples/backbone/
Angular version: http://todomvc.com/examples/angularjs/
Ember version: http://todomvc.com/examples/emberjs/
Knockout version: http://todomvc.com/examples/knockoutjs/
Four applications above which implemented by certain framework will be tested and measured by WebpageTest http://www.webpagetest.org/
Which one is the best ?
Angular and Backbone are both considered as the best for initialing a new project. The fact that you can not just pick the best one by its features or large community. If your project needs to work for all various Browsers, even if very old browser like IE6, AngularJS is looser since it just support modern Browsers. So you should not look up for “the best”, but for “the most suitable” for your project.
If you can not make the decision, or get confusing … you can do the more challenging and interesting ways – build your own framework🙂