← Back to Upcase

EmberJS / Backbone?


(Raul Murciano) #1

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?


(Sean Griffin) #2

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.


(Matthew Sumner) #3

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.


(Raul Murciano) #4

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?


(Bob Firestone) #5

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.


(Tom Dale) #6

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!