Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am a web developer and I'm starting to develop a web application on a large scale, but I'm not sure what framework to use. I was thinking of Angular.js, but I also considered Backbone.js. For you, what would be the best framework? or at least have a comparison between the two to see the performance.

share|improve this question
12  
If you are not really stressed out with performance requirements, do not just evaluate based on the performance of libraries. Verify the library roadmap, community support, ease of use, appropriate design pattern, etc. too. – Hasith Jul 12 '12 at 19:05

5 Answers

up vote 135 down vote accepted

Anybody here claiming that one solution is faster or slower than other either doesn't know much about any of these libraries or frameworks (or perf testing in general) or is a liar.

Performance is a very tricky characteristic to measure because of so many variables that affect it. Just to name few:

  • quality of the test/benchmark code
  • quality of the library/framework code
  • type of application
  • quality of the application code
  • browser used
  • client hw
  • other processes running at the same time on the client hw
  • quality and speed of the internet connection
  • server load and server performance
  • and the list goes on and on...

but more importantly, what exactly do you mean by performance? performance is a very broad term that covers too many things, including:

  • time it takes to bootstrap the app
  • time it takes to respond to a user action
  • resource utilization (cpu/memory/network)
  • performance of dom manipulation done by the library/framework/app code
  • garbage collector friendliness
  • and again the list goes on and on...

The best way to answer your question is to create an application that is well representative of the application you are intending to build and implement it with the competing libraries/frameworks. Then write a quality benchark that will compare them head to head in a stable environment.

This is obviously a very laborious task and only someone with a lot at stake would undertake it.

There is however a different solution to this problem: understand the framework/library you are using and specifically:

  • learn the core flows and algorithms that the framework/library internally uses. while you typically shouldn't care, when you get into a perf problems, understanding how your application executes, will enable you to identify and fix perf problems
  • check if performance is something that the library/framework writers have expertise in
  • check if the framework/library helps you to identify performance problems and fix them

As for the actual comparison between Backbone and AngularJS, you are comparing two very different solutions.

Backbone doesn't do any dom manipulation for you, so the speed of your app will mostly depend on how well can you do dom manipulation (is this your expertise?).

AngularJS does most of the dom manipulation for you and we have a ton of expertise in this area, so unless you are really good, you'll have a hard time matching us.

Secondly, backbone's model mutation observation is based on events, model wrappers and use of artificial getters and setters. Not only that this can be very inefficient due to lack of event coalescence (there might be a workaround for this in latest backbone versions), but the use of artificial getters and setters also interferes with the JIT compiler in your browser.

Misko wrote up a long post on how Angular does its magical model mutation observation. So I'm not going to repeat it here. But basically the performance of an AngularJS app is directly related to the number and complexity of bindings used in the current view of the application. With this in mind, you can easily predict Angular's performance. Even better is that with tools like AngularJS Batarang extension for Chrome, we allow you to easily instrument your application and understand which bindings on the page are slow and this allows you to focus on fixing the parts of your code that really matter.

I'm going to conclude by saying that no library or framework will be the best solution for all of your use cases, so you should learn more about the tools you build your apps with and when it really matters, decide which one is the best for a given use case. My bet is that for most of the apps you are going to write, performance is not going to noticeably change if you switch framework or library. So I would put more weight on other factors like productivity, easy of use, testability, community and documentation before I would worry about performance.

And the very last thing: benchmarks are often misleading, but check out these ones and take them with a grain of salt.

share|improve this answer
5  
Perfectly agreed with what you said but i wanna add while selecting a library to build an app a lot of time the personal choice also matters a LOT because it matters if the developer feels comfortable writing an app on the top of the library , which directly involves the developers understanding and agreement of the concepts used by the parent author for it. For example few developers like jQuery while few like Prototype – Darkyen Aug 22 '12 at 7:18
1  
Interesting answer, but why not say directly simply that Angular has more strengths than Backbone on performance questions? Although you are trying (too) hard to say that "it depends", I'll leave with this impression! – lajarre Jan 16 at 0:28
Awesome Answer...I love the way you provoked !!! – Praveen Prajapati May 20 at 9:22

have a look at knockoutjs too. Look at the video to get an understanding of how MVVM works in javascript world.

http://knockoutjs.com/

I have used it for few projects and so far very happy about it. I see it being a part of new ASP.NET MVC 4 (SPA), and backed by Microsoft.

share|improve this answer
1  
Ok, thanks. I was searching the web and found this very interesting: paulhammant.com/2012/04/12/… – jonatanes Jul 12 '12 at 19:20
1  
We looked into this Pauls findings and we think that just as Paul suspected, the angular's performance wasn't accurately measured because selenium couldn't reliably tell when we were done rendering. – Igor Minar Jul 16 '12 at 4:32

not necessarily an answer but another resource link w/ a generic pros/cons for each framework. I think what Igor Minar said is really important, focus on what is easy to learn, easy to implement & doesn't get in the way of your productivity over obsessing about performance.

http://codebrief.com/2012/01/the-top-10-javascript-mvc-frameworks-reviewed/

For what it's worth, Angular JS and Ember JS appeal to me primarily because of their use of binding is very much like Flex's binding mechanism (at a high level) AND it leaves the HTML mostly decoupled from the controller/model logic.

share|improve this answer

There is another performance comparison between Angular, Ember, and KO here:

http://jsperf.com/angular-vs-knockout-vs-ember/2

Clear winner in this case is Angular, but as said earlier, performance tests are rarely straightforward or fair.

share|improve this answer

Judging from the benchmarks and comparison I've seen: AngularJS

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.