Created
December 5, 2010 07:18
-
-
Save addyosmani/728910 to your computer and use it in GitHub Desktop.
Explorations into JavaScript MVC Solutions, December 2010
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Knockout JS - Knockout uses MVVM (which can be considered as MVC with declarative syntax). It's very much catered to those using JavaScript for user interfaces but does also provide dependency management, templating and works well with jQuery to boot. What I will say for Knockout is that it can make heavy usage of data-binding. If you're not used to this, I would recommend spending time reviewing before choosing Knockout as your MVC solution of choice. It's clean and it does work quite well, but is a little different from what you might expect. | |
http://knockoutjs.com/documentation/introduction.html | |
Backbone - this is significantly easier to get started with than any of the other solutions I reviewed today, however, note that it's support for MVC isn't atypical. The (C) here stands for collections and you'll want to review just how close to 'expected' MVC this solution is before you use it. I recommend Backbone for those who like to work with jQuery and need to get started with MVC without a long period of learning. The first example below is one using Sinatra and Underscore so it's a decent look at how one may use Backbone in practice. | |
http://ryandotsmith.heroku.com/2010/10/a-backbone-js-demo-app-sinatra-backend.html | |
http://documentcloud.github.com/backbone/docs/todos.html | |
Eyeballs.js - this feels a lot more like 'true' MVC than backbone, however I found the use of their o_O() initialization function to be a little annoying (especially when using it extensively) - I know, a small thing. Eyeballs feels more like using MVC inside a rails app and so people with a rails background may find it relatively straight-forward to get started with. Where Backbone excels at ease of use and Knockout at it's suitability for UI development, Eyeballs excels at delivering what you expect from MVC. | |
https://github.com/paulca/eyeballs.js | |
JavaScriptMVC | |
JMVC provides a *lot* out of the box - depen management, templating, testing, special events - these things in addition to it being a very clean solution for those wishing to implement MVC in enterprise level applications make it an interesting choice. I would echo that similar to Eyeballs.js, those used to using MVC with rails will probably find JMVC relatively easy to get to grips with, however I personally found it to be something which requires more time spent learning and playing around with it than the other solutions listed. | |
My verdict: | |
Backbone.js is the solution of choice if you want to start using MVC in your project within an hour. It doesn't take a long time to get the hang of and is actually quite compact. | |
JavaScriptMVC will take you longer to get setup, however, it currently appears to offer the best option for enterprise level applications requiring MVC. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice writeup, thanks