Arguably the four most popular frameworks available today are Backbone.js, Angular.js, EmberJS and KnockoutJS. This section aims to provide a high level comparison of these frameworks.
The reason why it’s helpful to concentrate on these frameworks is that each one has been used extensively in the wild and provides excellent documentation and community support. This means you can be confident that any framework you pick will fulfil your requirements as well as having help and support available if needed.
Additionally, there is little difference in the quantity of features provided by each framework. However, their opinion and implementation differ on what approach you should take when building a web application.
Some frameworks tend to be quite flexible in the way you can work with it, whereas others prefer you follow their predefined conventions. These differences can make a framework more suitable in certain scenarios than others.
Focusing on providing a comparison between these framework’s philosophies ensures you can pick a framework that is compatible with your application’s requirements or suits your personal taste.
Backbone.js offers a flexible, minimalist solution to separating concerns in your application. As a consequence of its minimal solution, Backbone.js used without its own plugins is more of a utility library than a fully-fledged MVC framework.
It may appear that Backbone isn’t as fully featured as the other popular MVC frameworks available. Pairing Backbone with one of its add-ons like Marionette or Chaplin ensures that Backbone.js is as feature complete as other frameworks.
Backbone.js has a library of plugins and add-ons that can be used to provide any sort of functionality that your application requires. Its modular approach means you can fine tune Backbone.js to use a different templating engine should your application require it. Furthermore, the flexibility the modularity provides makes Backbone.js suitable when developing a web application with unstable requirements.
Pros: minimalist, flexible, great add-on / plugin support, unopinionated, great track record of being used in complex web applications (WordPress, Rdio, Hulu), source code extremely simple to read, gentle learning curve
Cons: Requires external dependencies (underscore), memory management can trip beginners up, no built in two way binding, unopinionated, requires plugins to become as feature complete as other MVC frameworks.
Angular.js is designed and built by Google and is quickly gaining popularity. The stand out feature of Angular is its use of custom HTML tags and components to specify the intentions of your application.
It provides a HTML compiler that allows users to create their own domain specific language; this can be an extremely powerful tool. The approach is different than other frameworks which seek to deal with HTML’s shortcomings by abstracting away the HTML, CSS and JavaScript by providing alternative ways to manipulate the DOM.
Pros: Dependency injection, backed by Google, testing framework built in, built-in form validation, directives, extremely easy to debug,
Cons: Steep learning curve, data-binding can be problematic for pages with large amounts of information, hard to implement transitions when showing / hiding views
EmberJS is an opinionated, modular framework that can be simple and intuitive to work with if you follow its guidelines on how an application is built the Ember way.
Its convention over configuration approach means it provides a good starting point to begin construction when compared to other frameworks.
If you’ve had experience working with Ruby on Rails you’ll find it feels quite familiar when you work with EmberJS.
Pros: Fast development and prototyping, little configuration required, convention over configuration approach, Ember Data makes syncing with JSON API’s much easier
Cons: Lacks extensive testing tools, hard to integrate 3rd party libraries due to its opinionated approach, initially has a steep learning curve, unstable API
KnockoutJS aims to simplify dynamic UIs with a MVVM (Model - View - ViewModel) pattern.
It provides declarative bindings that make it easy to build even the most complex UIs while ensuring that the underlying data model is left clean.
Custom behaviours such as sorting a table can be easily implemented via bindings in just a few lines of code.
KnockoutJS has fantastic compatibility support; it works on all modern browsers as well as legacy browsers (Internet Explorer 6).
Pros: Inter-application dependencies handled with a dependency graph ensures good performance even for data-heavy applications, data binding is intuitive and easy to learn, custom events allow for easy implementation of custom behaviour, great browser compatibility
Cons: HTML templates / views can get messy if lots of bindings are used, end to end functionality (url-routing, data-access) not available out of the box, no third-party dependencies
Which one to choose?
Due diligence should be paid before selecting a framework to use for your web application. The chosen framework may be used to implement complex or uncommon functionality as well as maintain the application for years ahead.
Here are some summaries to help steer your thought process on which ones to try out.
Use Backbone.js if: 1. Your web application has uncertain requirements and as a result flexibility is vital. 2. You need to be able to easily change or pull out parts your web application (i.e. templating engine). 3. You’d like to start with a minimalist solution to help understand the fundamentals of MVC frameworks.
Use Angular.js if: 1. You want your MVC framework to be backed by a large reputable company to ensure its reliability and stability. 2. The use of a domain-specific language could help reduce the complexity of my web application. 3. Your web application requires extensive testing to verify its functionality. You need a testing framework that has been built from the ground up to work with the MVC framework rather than against it.
Use EmberJS if: 1. You’ve previously had experience with Ruby and enjoyed using its convention over configuration approach. 2. You need a framework that helps develop solutions and prototypes quickly. 3. Your web application needs a framework to handle the interaction with a JSON API with very little effort required.
Use KnockoutJS if: 1. The MVVM pattern provided by Knockout is much more suitable for the structure of my application. 2. The framework and application need to support legacy browsers such as IE6. 3. Your application has a complex dynamic UI and as a result the framework needs support creating these as cleanly as possible.
0 comments:
Post a Comment