JS3

January 14th, 2009 by kowsik

You know about LAMP and I’m sure you know about RoR, not to mention countless other web application frameworks. I would like to introduce you to JS3 (since we are on an acronym roll here) which is turning out to be my favorite way to build applications. I’ve built apps for a long time now with MFC/ATL, Swing and WEBRick, mainly because I like to visualize things in order to understand. And when your prototypes start looking like the real meal deal and the lines start getting blurrier, you know you’ve hit home run.

JS3 stands for the JavaScript trio, Couch DB, Helma and jQuery. Before you get all turned off by JavaScript or think that it’s for Web 2.0 browser geeks, think again. The entire pcapr site is powered by JS3 with most of the pcap editing (Fragmentation, TCP stream reassembly, TCP rewrites, DoS generation) all happening inside your browser with JavaScript. And there’s not a single line of SQL in this site. Just map/reduce. Yes Jack, JS3 is cool!

Couch DB

I first got introduced to Couch DB by Adam back in November and OMG, no tables and no joins! Just JSON documents and HTTP for the actual queries. Couch DB is the brain child of Damien Katz (I’ve never met the guy). The DB is written in Erlang, what you store is JSON, queries are in JavaScript using map/reduce and powered by SpiderMonkey. Life just doesn’t get better than this.

Helma

Adam saves the day again and points me to Helma, which is not your friendly neighbor, but a web application framework based on Java with most coding done in JavaScript, powered by Rhino. Helma supports skins, macros and more importantly live updates. For the i-gotta-program-to-the-metal folks, you can always access your favorite C code through JNI and SWIG and still be able to access all your code through JavaScript. Since Helma uses extensive use of JavaScript prototypes, it’s pretty easy to organize your code into objects with actions that directly translate to URL paths.

jQuery

And finally we come to pushing your browser to its limits. If you think programming in the browser is about document.getElementById(), that’s so last year. jQuery introduces some pretty neat mass-edit paradigms with the right amount of terseness, it’s incredibly easy to build awesome looking UIs without a lot of code.

The really fun part of JS3 is that you work with JSON the whole way, from the database through the webapp layer to the UI. For example the tag cloud in the pcapr site is literally blasting the result of a map/reduce view from Couch DB to Helma and back up to jQuery where the div is populated with different font-sized labels based on the frequency of the protocols in the various pcaps. Guess who does all the hard work? Your browser!

Neat huh?

Posted in JavaScript, Tools | Permalink | Trackback

5 Responses

  1. cheng

    wow! so cool!
    I think i will be make a website with JS3!

  2. Robert O'Rourke

    Interesting stuff. I’m more of a front-end coder so using javascript at each level sounds quite appealing to me.

    I’d like to try it out however I’m not so hot on setting up the environment for it. Do you know of any resources that would guide me through setting it up on a *nix server up to the point of getting ‘hello world’ to run?

  3. kowsik

    Couch’s the tricky one since it’s not even at 1.0 yet and the installer has dependencies on the “right” version of Erlang as well as Spidermonkey. Compiling from source is the only way.

    As for Helma, simply untar the release and you can bring up the server in less than a minute.

  4. Ray Morgan

    Hey, in case you want another server side JS implementation check out Node.js (http://tinyclouds.org/node/). It is based on Google’s V8 + all aysnc/non-blocking IO.

    The downside is it is newer, so the libraries aren’t all there. But there is a CouchDB library.

  5. kowsik

    Thanks Ray, Will take a look at Node.js. The appeal of Helma was the extensive libraries available for it in addition to the skins and macros. Not to mention the native JS prototype support to organize the web apps URL mount points.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.