When comparing Backbone vs Ember, the Slant community recommends Backbone for most people. In the question“What are the best client-side JavaScript MV* frameworks?” Backbone is ranked 3rd while Ember is ranked 16th. The most important reason people chose Backbone is:
A lightweight view class is provided but there is no default templating method implemented. Because views are minimal it allows for much more freedom to implement views however you would like, and because of this freedom it's possible to write views to more uniquely adapt to a problem. User interactions are done within an events object that allows these interactions to be segregated from the rest of the view code which makes the behavioral aspect of the view easier to read and manage.
Ranked in these QuestionsQuestion Ranking
Pros
Pro Gives you the freedom to implement views however you want
A lightweight view class is provided but there is no default templating method implemented. Because views are minimal it allows for much more freedom to implement views however you would like, and because of this freedom it's possible to write views to more uniquely adapt to a problem.
User interactions are done within an events object that allows these interactions to be segregated from the rest of the view code which makes the behavioral aspect of the view easier to read and manage.
Pro Can be combined with any library you want
Backbone can be combined with any library of your choosing, giving you the ultimate flexibility in creating customized solutions for unique projects. Even the only two backbone requirements, jQuery and underscore can be replaced with equivalent libraries like zepto or lo-dash.
Pro Large community
Backbone has existed longer than most frameworks, and has a large following of users and projects using it as a framework.
Pro You can call underscore.js methods directly on Backbone objects
Backbone collections and models are extended by underscore.js method allowing you to call underscore methods directly on the Backbone objects.
Pro Easy to interface with the API
Backbone provides Model and Collection classes that provide strong analogs to restful resources. These strong analogs allow you to interface more naturally with the API, and makes it easier to write custom behaviors for more complicated API interactions.
Collections provide a variety of powerful manipulation methods that are integrated from the underscore library, that allow you to manipulate, sort, and filter collection data easily.
Pro Easy to implement complex user interaction
Because all the state is managed by Models and Controllers, and they are extendable objects, you can isolate all the state logic onto those objects allowing the rest of the application to not worry about it. The app is simplified to just taking in input to modify the Models and Controllers, and updating the views to reflect them, but none of the state needs to be a concern outside of the Model and Controller classes.
Pro Doesn’t force you into a particular coding style or paradigm
There is no “magic” happening below the surface: the source code is clear, readable and well commented. Backbone is also “lightweight” in the sense that it doesn’t require a ton of buy-in to use. It can be easily integrated into an existing page, and you can choose to only use certain components of the library (Views without Models or Collections, for example). While there are many frameworks that seem to be faster to get started with, Backbone’s lack of surprises, clear documentation, speed & flexibility make it a good fit for all types of apps.
Pro Extendable with plugins
Because Backbone is so simple, and the different components are very well isolated, it is very easy to extend the functionality of Backbone. If you're writing your own extended code it's easy to keep it separated out, and share with the community.
The community also has many plugins already available, which you can pick and choose to use to fit your programming style.
Pro Easy to abstract interaction
All Backbone classes extend an events class that allows for listening and triggering functionality. Because all classes implement events by default it is easier to provide asynchronous communication between objects, and it allows better abstraction of interaction so the event emitting object does not need to know the structure or existence of the receiving object.
Pro Opinionated in terms of application structure
Ember already defines the general application structure and organization for you. This was done to prevent developers from making mistakes which would needlessly over-complicate their application. While it's still possible to go out of these practices forced to developers by the Ember authors, you still have to go out of your way to force them.
Pro Ember-CLI
Ember-CLI is a very useful tool. With just a couple of commands it scaffolds the code, installs dependencies and finally compiles everything itself. It's very useful to quickstart an Ember project.
Pro Uses Handlebars
Ember's preferred templating language is Handlebars. This is mainly because Handlebars is a logic-less templating language and Ember tries to keep it's logic outside the view.
Another reason why Ember benefits from Handlebars is mostly aesthetic as Handlebar's clean syntax makes for easier to read and understand templates.
Finally, Handlebars templates are compiled instead of interpreted, which means that they are much faster to load.
Pro Convention over configuration
Ember follows the philosophy of "convention over configuration" meaning that it already has almost everything configured for you, so you just have to start coding and developing your project right away.
Pro Complete front-end stack
Ember is practically a complete full-stack front-end framework. It comes with it's own asset pipeline, router, services etc...
Pro Completely community based
Pro One of the fastest template rendering engines (new glimmer)
Pro Easy to understand documentation
The Ember Guides are well structured and very well written. The API documentation is also fantastic.
Pro Ember's Object model makes the framework extremely consistent
Most of Ember's components come from the Ember Object Model. It's the basis for views, controllers, models and even the framework itself. This means that the framework is extremely consistent since almost every component shares the same core functionalities and properties since they are all derived from the same object.
Pro Excellent routing
Route handlers for the URLs can see a wide range of possible application states, asynchronous logic in the router makes sure of Promises. And implementing makes sense.
Pro The run loop
It batches bindings and DOM updates to increase performance; if similar tasks are added to a batch, the browser would only need to process them in one single go, as compared to re-computing for each task one at a time.
Pro Excellent API
Ember's API are really easy to understand and work with. It has methods which allow you to harness complicated functionalities in an easy to understand way.
Pro New router has less boilerplate code
Ember's new router need much less boilerplate code that it previously did.
Pro Debugging tool for almost every web browser
Ember also has a debugging tool called Ember Inspector which is used for debugging the client side of your app.
Pro Works great with jQuery
You can use any of jQuery’s features.
Pro Useful bindings
EmberJS provides with an extremely handy feature of advanced bindings. With this you can not only set the path to the binding value in your app but also set in which direction you want the changes to propagate to (oneway
, single
, multiple
etc).
Pro Promises everywhere
Promises represent an eventual state in asynchronous logic. Having promises everywhere (almost) means you could write simple and modular code, using almost any API that Ember provides.
Pro Computed properties
Having custom properties in your templates is itself a huge plus but having custom computed properties is an even greater benefit, since now you can code your custom function as a property and call it from your template. Hence rendering your page exactly according to your needs.
Pro Built-in router
Ember comes with built-in routing capabilities. There's no need to install third-party plugins to be able to use routes.
Pro Auto-updating templates
If you've used handlebars (Ember.js's templating is powered by HandleBars) helper tags in your code (like {{#each}}
) you won't have to worry about updating your template each time you add/remove data from your page, Handlebars will auto update your template for you.
Cons
Con Requires more coding compared to other frameworks
Because many features are not provided out of the box, you either have to write more base class code to get those features, or find a plugin that provides them in a way you like.
It does not provide much structure either, things like memory management must be kept in mind by the developer, also the lack of view lifecycle management makes state changes prone to memory leaks.
Con Can easily lead you to spaghetti code
Heavy event-binding can lead to unmanageable spaghetti mess. BB tempts users to overuse it for no reason.
Con No data binding
Backbone does not have data binding support. However, there are some libraries that can be implemented in order to have data binding in Backbone. Such as Epoxy
Con Large library size
At 69Kb gzipped, it is one of the largest JavaScript frameworks. This means Ember might be an overkill to use on simpler projects.
Con Very opinionated
Ember (and many extensions, like Ember Data) force the implementation down specific architectural paths. These paths are what Ember believes is best practice and typically are fine, but not in all cases. This can occasionally lead to fighting with your framework which is never productive.