Which MV* framework do you recommend?
|
closed as not constructive by casperOne♦ Nov 14 '12 at 21:54
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.
I wouldn't call Backbone a MVC framework (and AFAIK even the authors don't call it MVC). It's very lightweight, which means you have to type more, but therefore might be a good fit for a broader spectrum of apps. Backbone is based on the awesome model, and observation of this model. AngularJS is way bigger, provides a much higher level of abstraction and is very opinionated on how you should develop your app. It's a complete solution, with testing environment and philosophy behind it... That means, building an app is super fast, but it doesn't have to fit everyone nor every app. Note, I'm a member of the AngularJS team, so this might not be objective :-D |
|||||||||||||||||||
|
I am currently working on a major project which is currently built on top of Backbone and JQuery. My foray into angular has been for the past few days and am still getting my head around it. Coming from a Flex world, HTML and JS seem like a step back. ( Not trying to incite any kind of a debate here! But this is just my personal opinion.. ). Like the authors of Angular profess, HTML is made for static documents. Its not meant for dynamic apps. So, given the fact that Flex was built specifically for dynamic RIA's it should be easy to see the logic. Edit :*I ported my Backbone application to angular. The Code size went down from 5k lines of code to guess what? 750 lines. Not just that.. The code is much cleaner.. Earlier, there was a huge technical debt attached to this implementation in backbone.. Each time I had to sit with it.it took me quite a while to understand all the hooks and how the individual models and classes and views interacted together.. ..Now its a breeze.. * Now, the chosen libraries help you. I have to admit it. Coming from writing pure old javascript/ jQuery to using Backbone has been a huge leap. Your app is now pretty well structured, thanks to the MV* division of concerns. You have views, models and templates. While Angular banks completely on data binding, Backbone has no direct way of specifying any kind of two way data-binding. The advantage of Backbone is that its not opinionated. It has none whatsoever except for structure. It just asks you to split your app into models and views and start putting them together. Thats about it. This is advantageous in terms of separation of concerns. But thats where the buck stops in Backbone. You can of course use meta-frameworks / plugins built on top of it like Backbone LayoutManager or Backbone Marionette ( I use Marionette ). This makes creating one level higher structure than what Backbone gives you. Marionette, for example takes care of closing views and showing them. Takes care of removing events when you remove the view from the DOM etc.. This helps you to not clean up after yourself. It helps.. For a person coming from the Flex world where everything is provided to you off the box as a component and all that you need to do is include an xml ( declarative way of defining UI! ) to say specify a Data Grid or any such complex component imagine going back to div's and table's in order to specify your UI. Its like starting to code in assembler after you are writing code in say a 4th Gen Language. Its powerful but you have to write everything ( almost ! ) from scratch. Of course, you are provided some kind of higher level application components in JQuery UI. You have tabs, accordions and such basic stuff. Lets take an example... tabs. To include JQuery UI tabs in your HTML, this is what you need to do. ( Taken directly from JQuery UI site )
In Angular if you use directives you could do the same using :
The beauty is that someone else would have written the JS file ( exactly as JQuery UI! but I think you can notice the difference! ), I don't know call it a plugin? call it a component? You do see how very terse your code is now? Now this gives way for a component architecture. What do you need for developing RIA's? Yes, a Rich Component Architecture. What Angular is creating is the ability to write this architecture. Of course, Backbone gives you the ability to "extend" a model. This basically means that you are creating an object of a class called Backbone Model ( or a class derived from it..) Angular doesn't do that. It says declare variables in this scope and It will take care of all the changes to those variables. Pitfalls currently in Angular: Its an extremely new framework. So the number of tutorials and screencasts you are going to find is limited, which means that you have go to the source, become Neo. ( This is in comparison to Backbone which is now perhaps one of the most famous MV* framework! ).
Pitfalls in Backbone :
|
|||||||||||||
|
Having worked professionally with both Backbone.js and Angular.js -- with brief usage of both Knockout.js and Spine; I do have some idea of which is "Better". I'm a huge fan of Angular.js as it lets you write very intuitive code which let's you create apps without including extra libraries; such as: jQuery, Underscore.js etc. It's purely Angular, then your scripts(s). As the "To-Do MVC App on the Client-Side" has become the de-facto way of demonstrating a frameworks prowess; I suggest taking a look at To-Do MVC . Note the required libraries in each project and the actual code. The choice is fairly obvious! |
|||||
|
Surely the argument between the two frameworks should be focused on what is the better 'MVC, MVP' part of it. Any other extra feature can be ported in via another library or framework. You don't need a testing framework with your mvc. You can load in an external one. Angular.js Pros: You don't have to write all the event listening and event triggering. Its automatic. Cons:
Backbone.js Pros: Truly enforces seperating concerns between model, view and controller, is lightweight, and easier to maintain or change in the future. Allows more control for the developer to handle anything. Although with control comes responsibility. Cons: A bit clunky, always having to create both the event trigger and event listener in all all view, model, router etc, which makes for larger code and longer figuring it out writing it. Conclusion: Do you want control, and compatibility with other frameworks? Use backbone. Do you want to write something more quickly in a language that isn't technically javascript which has extra bloat? Use Angular.js |
|||||||||||||||||||||
|
I think they are roughly equally powerful. I suggest that you choose the one which you like better, based on your personal (or institutional) preference. Both are a Model-View-Controller framework: MVC. My personal preference is the Model-View-View model framework: MVVM. To me, MVVM is harder to pronounce, but easier to use. MVVM is the framework behing Silverlight applications, and there is a wonderful Javascript version called KnockoutJS. |
|||||||||||||||||||||
|