Building browser-based web apps, with Backbone.js
This week's Async, with Aron Carroll and Premasagar Rose, is about creating browser-based web applications, using the "MVC" library Backbone.js.
Web apps are increasingly dependent on a more intelligent layer of JavaScript in the browser. Helper libraries, such as jQuery, are indespensible for keeping the client-side logic sane, but anything more than a simple piece of software can soon get tangled in a spaghetti mess of code - event listeners, callbacks and DOM manipulations that can be fragile and tricky to maintain.Backbone is a tiny library that brings back a degree of clarity and control. It's inspired by the MVC approach of separating the Model (the data that the client reads from and writes to the server), the View (the DOM, and all the snippets of HTML that create each part of the user interface) and the Controller (the collection of code that orchestrates the behaviour of the app).
Backbone makes it a breeze to have the user interface listen for changes to the data, and update accordingly. In a similar way, changes to the local data can be automatically sent back and synchronised with the server API.
It's built on top of the brilliant Underscore.js, a handy swiss army-knife for manipulating arrays, objects and functions, and also takes advantage of jQuery or Zepto (a light, jQuery-like library for WebKit-mobile), if one of them is present.
Altogether, it's a joy to use. Backbone avoids the constraints and burden of more heavyweight frameworks, and uses its expressiveness and lightness to put the fun back into app development.
Aron and Prem will explain both Backbone and Underscore, and share their experiences of using the libraries on their recent projects.
Show Notes
The source code from the talk is up on GitHub for those interested in having a poke around.http://github.com/aron/async-backbone-talk