Client-Side MVC Roundup
Join the DZone community and get the full member experience.Join For Free
here is a breakdown of the alternate technologies in the client-side mvc space. what i’m showing, in graph form, is “lines of code” analysis of the well-known reference todo list app implemented in each of the competing technologies:
breaking the examples down into groups.
in order of terseness, all of batman, angularjs, knockout, olives, o_o, dermis, agility, knockback and montage all extend html with turing-completeness. that is the equivalent of if/else conditionals, and looping structures. the html is non-standard as a result, and is it’s own template. batman, angularjs, knockout are the ones with recognition.
<ul id="todo-list"> <li some_extra_attribute="some looping expression"> <!-- # more html logic incl template stuff. --> </li> </ul>
<ul id="todo-list" some_extra_attribute="some looping expression that's about the 'li' inner..."> <li> <!-- more html logic incl template stuff. --> </li> </ul>
this group is my preference.
in one case, the templating is in the html, but there’s no directives around turing completeness.
part html, part separate ‘html’ template
there are large communities around backbone, ember, and spine, yui. larger communities than for the turing-complete html ones above. backbone is half way up the terseness leader-board (as you can see). lesser known are the others in the space are sammy, socketstream, staples, somajs, epitome, dijon, plastronic, troopjs, google’s closure, puremvc. those last, in terseness order again of course.
this group has templates hived off into script tags …
<script type="text/x-handlebars"> // template stuff here, incl html and turing-complete logic </script>
<script type="text/x-handlebars-template"> // template stuff here, incl html and turing-complete logic </script>
<script type="text/template"> // template stuff here, incl html and turing-complete logic </script>
… or totally separate .html files. thus they do not “pollute html”. it also means that the though that would repeat, or would be conditional is missing from the intended ‘place’ in the source code (or the dom depending on your point of view).
reminiscent of html, but not html ‘source’
dart is either in this category, or the last one. at least, i say that after inspecting the todomvc example source. there’s a html page that contains the ‘outer’ application, but dart is composing html fragments for todos in code and injecting them where appropriate. sure the language is easy to read, but it is questionable to tape strings together to make html in procedural code.
any technologies i didn’t mention in the first two categories, are in here (except gwt, which is it’s own thing).
even better if …
addy osmani’s and sindre sorhus’s todomvc site is fantastic. it allows people who care to compare implementations. it could be better though – branches for each implementation, with greater consistency between examples. also, i’m not sure how much patronage it gets from the makers of each framework. is each example canonical? are they all exactly the same functionality.
there’s also the question of server side interaction. all but a couple of these example apps have no server-side persistence. a get of the todo-list and put/post of it going back to the server for posterity, would help complete the terse/elegant vs. verbose/confusing picture for people wanting to make a choice.
method and accuracy
there’s a couple of shell scripts in the root of http://github.com/paul-hammant/todomvc . there could also be different functionality or idiomatic correctness for each of the frameworks. thus batman vs angular (the left-most two frameworks), or any others, could change position were the experts to review the source, and contribute to the todomvc project on github.
Published at DZone with permission of Paul Hammant, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.