Tag Archives: jaxer

The Brave New World of Server-Side Javascript

8 Jun

Not the B Team

Not the B Team

Every once in a while I hear whispers of server-side javascript and I get just as excited as the next person. But, I’ll admit that until recently a phrase like “Javascript on Rails” was on the same level as a phrase like “McGyver vs. The A Team – The Movie.” Fictonal. But awesome in theory.

(Don’t worry, they eventually join forces in the sequel)

But what about Jaxer?

My limited experience with server-side javascript (SSJ) has been through Jaxer, from Aptana.  It touts some cool functionality, like loading the DOM server-side and built-in database drivers for MySQL, with the former allowing for DOM manipulation and integration with libraries like jQuery.

The extremely original Gear logo

Ubiquitous "Gear" Logo

But, in its attempts to blur the lines between client and server execution, Jaxer has made sacrifices in its extensibility. It is meant to be plugged into another system. For instance, I don’t know of an easy way to expose data through a RESTful JSON/XML API (like so many sites are doing nowadays) using Jaxer alone.

What I’m really looking for in SSJ is something akin to the ecosystem surrounding languages like Ruby and Python.  That’s why I was pleasantly surprised to stumble accross a few projects that aim to do just that.

Narwhal – Javascript Standard Library and Interactive Console

The foundation of any good ecosystem is a standard library.  Enter Narwhal, “a flexible javascript standard library.”

There are a lot of things to like about this project, but the primary benefit is its attempts to play nice with multiple javascript runtimes like Rhino and V8cgi.  Also, this project is embracing Mozilla’s ServerJS standard which I think is important for its longevity and interoperability.

Setup is a breeze, you can simply clone the project from github:

git clone git://github.com/tlrobinson/narwhal.git

Once you add narwhal/bin to your $PATH, you can use the convenient symlink js to enter an interactive javascript console similar to irb or python.

Jack – Javascript’s “Rack”

Interestingly enough, Narwhal came into existence as it’s author, Tom Robinson, was working on Jack.

JSGI is a webserver interface for JavaScript inspired by Ruby’s Rack (http://rack.rubyforge.org/) and Python’s WSGI (http://www.wsgi.org/).

Jack is an implementation of JSGI compatible handlers (to connect to web servers), middleware (to intercept and manipulate requests to add functionality), and utilities (to make using JSGI easier).

Setup is also breezy. Simply clone Jack into the same directory you cloned Narwhal into:

git clone git://github.com/tlrobinson/jack.git

Since you’ve already added narwhal’s bin directory to your path, lets just make a symlink to jackup from there.

From your narwhal/bin directory:
ln -s [path/to/jack]/bin/jackup jackup

Run jackup -h for usage.

So, what’s next? Where’s Javascript on Rails?

With Narwhal and Jack, you can start writing basic web apps. Looking at the example.js script in jack/examples we can see the basic request/response structure. Looks familiar huh?

var Jack = require("jack");

var map = {};

// an extremely simple Jack application
map["/hello"] = function(env) {
    return [200, {"Content-Type":"text/plain"}, ["Hello from " + env["SCRIPT_NAME"]]];
}

// apply the URLMap
var app = Jack.ContentLength(Jack.URLMap(map));
//...

While these two pieces are a good start to a vibrant server-side javascript ecosystem, there’s still a long ways to go to before it’ll be on par with Ruby and Python.

What SSJ needs is its Django/Pylons/Rails/Merb. There are a couple of projects I’ve found in the wild that are using Jack and Narwhal, but they appear to still be in very rapid flux.

Nitro

Nitro provides a library of carefully designed middleware and utilities for creating scalable, standards-compliant Web Applications with JavaScript.

Helma NG

Helma NG consists of several components that can be used together or alone:

1) A compact JavaScript runtime environment based on Mozilla Rhino. It adds
to Rhino a reloading module system that is compatible to the ServerJS
Securable Module proposal.

2) An interactive shell with support for autocompletion and history.

3) A module library implemented in JavaScript, covering basic functionality
such as extensions to the built-in objects, file I/O, logging, persistence,
client and server side HTTP support and more.

Why Aptana is Quickly Becoming the Killer Stack

26 Aug

Anyone who knows me knows that I am a huge fan of Aptana.  (The recent acquisition of the pyDev plugin and its eventual incorporation into the IDE only solidifies that position.)  Their suite of services are quickly turning into the killer app stack for a large majority of web developers including myself and if you’re a developer who hasn’t given Aptana a try, I highly recommend you do – it’s free.

Yes, everything they’re doing has been done before.  And yes bigger and badder players have offerings in the IDE, cloud hosting, and developer community sectors, but it’s all about consolidation baby, and Aptana wins hands down in that arena.

The IDE Is Key

The foundation of any good development stack is not the test or deployment servers.  It’s not the language,  documentation, or even the community.  It’s the IDE, damnit.  Because, really – what connects all the other layers?  It should be the IDE, and that’s exactly what the Aptana IDE does.

The Aptana devs have done an excellent job in providing much more than just a text editor with syntax highlighting.  With the soon to be released Aptana IDE 1.2, you get project management, remote asset management with FTP, SVN and their new aptanacloud interface, database management, code tutorials and assistance for popular libraries and frameworks.

No, Aptana will probably never be as good a PHP editor as Zend Studio.  And it’ll probably never be a replacement for Cyberduck or Filezilla for file management, or Amazon’s web services for cloud computing.  And you’ll probably still try to ping the jQuery docs only to realize they are still slow as hell (good alternative here, btw).  But, in the Get Stuff Done web development world, having a working solution for all these built in to your IDE is invaluable.

The Future is in The Cloud

As a relatively new entrant into the web technology world, I would venture to say that the biggest and most exciting development during my short tenure is Cloud Computing.  But, I’ve said it before, and I’ll say it again – managing Amazon Web Services and EC2 instances is hard work.  Google App Engine fixes the hard work problem, but you’re forced into Google’s narrow framework and constraints.

Aptana’s new Cloud service is right smack-dab in the middle.  You’re given a sliding scale of server size, a couple of customization options, and bam! you’ve got a web server.  There’s no 50 step, command line based, get-one-step-wrong-and-you’re-hosed process to build and deploy a machine instance.  But, you also don’t have the fine-grained control of exactly what software your server runs.

That’s an easy trade-off for the web application developer, because execution on the core functionality of your app is what matters.  No one really cares how you’ve squeezed every last ounce of optimization into your server cluster (though there’s nothing wrong with that pursuit).

Oh, by the way, did I mention that Aptana Cloud is integrated with the Aptana IDE on every level – database management, source control, resource management, deployment, etc. etc?  Yeah, it is and it kicks ass.  Go sign up for the early access program and see for yourself.

Javascript is the New Cranberry

You know how you can walk down the juice aisle at your local grocery store and see 50 different juices and cranberry just seems to be involved with every damn one of them?  That’s javascript in the web world.  More often than not, JSON is the platform of choice for APIs and web services.  AJAX pervades just about every Web 2.0 application.  Hell, it’s even made it into our databases with CouchDB.

Hey, there’s nothing wrong with that – Jeff Attwood may hate working with javascript – but I kinda sorta almost maybe like it!  Especially when working with frameworks like jQuery, javascript can be a fun experience when it adds interactivity and wow-factor to your web application.

Enter Aptana’s end-to-end Javascript solution – Jaxer.  Damn, they thought of everything!  If web developers are spending so much time in their code interfacing with javascript APIs and writing Javascript UI interactivity, why not put javascript on the server side and use it as your middleware?  I like it.

Hell, I can see in the near future a scenario where Javascript is the only scripting language in an entire application.  Front end javascript, with Jaxer on the server, and CouchDB as the data-store.

Oh, and did I mention that Jaxer is integrated into the Aptana IDE with a debug console, profiler, etc? Ok, you get the point.

So Why Did I Write This?

Sounds like I’m a pretty hardcore Aptana fanboy, doesn’t it?  Well I can assure you the Aptana team hasn’t paid me should be paying me to say all this, damnit.  Oh well, I’ll throw in a diss just for good measure.  For some ungodly reason, the Aptana IDE only just recently added a word wrap feature.  Yes, you read that right – word wrap.  Word.  Wrap.

Ok, they maybe might have had some sort of plausible excuse, but damn – Word. Wrap.  That’s sort of like a television not having volume control, or a keyboard without the tilde – you don’t miss it until you don’t have it.