100% Javascript Web App Architecture

1 Flares Twitter 0 Facebook 0 LinkedIn 0 Google+ 1 1 Flares ×

Imagine creating a Rich Internet Application (RIA) built entirely using JavaScript, from client to server.  What would it look like? I’ve already discussed the benefits of HTML5 and the coming Web 3.0 movement in recent posts so I will not into those details now.  Instead, I want to focus on what an application like that might look like.

First, to review the new resources at our disposal with HTML5: Because of the required implementation of the HTMl5 spec localstorage(), you will now have a much greater facility for maintaining persistence across the user experience and even over the lifetime of the user. The implementation specification calls for a robust key/pair database that can store up to 5MB of data and doesn’t necessarily ever expire (ideal for storing JSON objects). Second, security provisions now allow for cross-domain AJAX calls, enabling mashups of disparate data sources, directly in the client application.  Third, js workers are now a native concept, allowing background processes for intensive JavaScript processes, to now kill browser memory.  Fourth, native support for media, enabling bidirectional control of audio/video by the DOM and vice versa. Additionally, libraries for rendering sophisticated SVG graphic and even drawing real-time on the canvas. These resources provide tools for a much deeper user experience and will provide the opportunity to create a fatter client application, shifting much of your central logic to the client.

Meanwhile on the server side, a substantial amount of momentum is building behind Node.js.  In fact, check out Node.js on GitHub and you’ll find it now has more followers than Ruby on Rails. The promise of Node.js is an extremely thin event-driven framework for creating web services entirely in JavaScript.  The benefits of this approach are (a) an extremely fast framework that avoids thread locking and an all-JavaScript developer experience, which provides for both faster development and less team bifurcation.  Node.js is also ideal for managing long-session connections which might be used for media or chat sessions, etc.

Node.js Popularity

There has also been a lot of interest in NOSQL (“not only SQL”) databases, that are document  rather than table oriented.  So, instead of a structured pre-defined schema, you simply store your own data in a structured way that can be independently structured from any other document.  The documents are essentially serialized JavaScript (JSON or the binary equivalent BSON) and are ideal for persisting data objects from the software.  In fact, wasn’t this largely the goal of bridging ORM technologies such as Hibernate?

javascript ArchitectureSo where is all of this going?  If we look at the technology stack we now have available, it is natively JavaScript from top to bottom, with persistence resources on both the client and server, that are both ideal for storing serialized JavaScript objects.  Combine this with the deep integration of media and imaging, as well as support for AJAX web service integration across any domain, not to mention the proclivity of JavaScript developers toward  a fat client architecture – I think you have a recipe for a popular new fat client architectural paradigm emerging.

Considering mobile, it is ideal not to have page refreshes more than necessary.  With a web application architecture that is much less dependent upon server-side page refreshes, this could be a much simpler alternative to building complex native mobile apps, using Objective C and still another version in Java for Android.  And with all of the media resources implicit in HTML5, it appears we’re going to see much deeper still, RIA user experiences, which again benefit from a fatter client and thinner server application. In this paradigm, the server application is minimized to a collection of web services in support of the fat client application, which aren’t even an exclusive provider for the RIA application, since it can also not pull directly from other external resources providing JSON web services.

Node JSObserving other early indications of movement toward this model, Yahoo is set to release a new platform called Mojito, which seeks to “blend” the server/client paradigms into one cohesive development experience.  It is essentially built upon Node.js on the backend and YUI for a rich AJAX library on the client side. There is a whole philosophy they are building around the best practice for developing RIA JavaScript-centric web applications that service mobile and desktops alike.  Or you could assemble your own stack using JQuery and Backbone.js on the client; Backbone.js in particular is an MVC framework for JavaScript and may prove particularly useful as you begin building more complex “fat client” applications.

This movement toward deeper JavaScript’ing and richer user experiences online, began in 2005 but stopped short due to key limitations of AJAX, media, and persistence, though I think many saw the promise.  With those key issues now solved, I very much look forward to seeing a continuation of interface innovation that leads to further refinement in both architecture and user experience.