EmberJS / Backbone?

After reading your recent blog post about EmberJS, and given your experience with Backbone, I was wondering: which kind of apps do you consider a better fit for each framework?What kind of features, UIs, constraints, workflows, etc make more pleasant to develop with Backbone vs EmberJS? What criteria would you apply before deciding which framework to use in your next Rails + JS app?

Backbone and Ember cover completely different ranges of applications. Itā€™s somewhat like comparing Rails to Sinatra, or even to Rack. Ember is a heavy weight framework thatā€™s better suited towards large scale, complex, single page applications. Backbone is less a framework, and more a collection of ideas. Itā€™s light weight, and applies more or less anywhere that jQuery applies. Using Ember for an application that will have only a little JavaScript would be like taking a sledgehammer to squash a mosquito. Similarly, if you end up trying to write a larger application in Backbone, youā€™ll ultimately end up having to write your own framework around it.

I personally prefer Angular over Ember for larger applications. Iā€™m not a fan of several of Emberā€™s design decisions (it has its own object model, it monkey-patches Function#prototype, etc.), and several pieces of Angular (mainly how it handles templates) fits more nicely in the Rails stack.

1 Like

I think that trying to think of ember as a single page app is the wrong frame of mind. One of the most powerful features about ember is itā€™s router and use of the URL.

As the homepage states, its for building ambitious web applications. Like rails, itā€™s opinionated and getting started can be frustrating. There is an Ember way to doing things and going against that leads to a lot of heartache later on in development. Thereā€™s a steep learning curve, but there is gold at the end and I think itā€™s worth working through.

Iā€™ve been very happy with developing in Ember but it is by no means for adding a bit of javascript spice to your application. If your just looking at a small part of your application Angular, backbone or just jQuery are certainly better options.

Thank you both for your comments! I seeā€¦ would you recommend Angular or EmberJS for an app where only some pages have JS-based UIs, or thatā€™s a better fit for Backbone, even if those individual pages are highly interactive and stateful? How easy would be switching from a Backbone-based app to an EmberJS one? If youā€™re launching a prototype you know youā€™ll be iterating a lot and donā€™t know what the app will end up looking likeā€¦ In such cases I always feel comfortable with Rails in the server side, but Iā€™m still kind of lost when it comes to choosing a client-side framework.

As an aside, what about testing ā€“ have you noticed any major differences between both frameworks?

In the case of having a couple of pages that need the interactivity of a single page app I would say go with backbone or sprinkle a little jquery and stick with turbolinks.

I havenā€™t really used ember. When it hit 1.0 I played with it, got frustrated by the docs and gave up after an hour. I have been told that the situation has improved but havenā€™t yet gone back.

I work on a large enterprise rails project where we are using angular on some pages and it leans towards the ugly side of things. How it is being implemented using a simple ng-app is a no go. We have to manually bootstrap every section where we use it or it takes forever to load correctly. Also the actual angular.js javascript include canā€™t be included in the application.js file because it will parse the dom on every page using angular or not making the page feel sluggish.

Disabling prototype extensions is super easy (literally one line of code). The claim about Angular templates working with Rails better is new to me. Would you mind unpacking it? We definitely designed Ember to be a better fit for people that adopt the Rails worldview. Thanks!

1 Like