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.
|
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:
but more importantly, what exactly do you mean by performance? performance is a very broad term that covers too many things, including:
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:
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.
|
|||||||||||
|
have a look at knockoutjs too. Look at the video to get an understanding of how MVVM works in javascript world. 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. |
|||||||||
|
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. |
|||
|
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. |
|||
|