by Savio Rodrigues

JavaScript enters the server room with Node.js

analysis
Sep 3, 20106 mins

Here's what to expect from the hot new server-side framework that promises to deliver highly scalable apps on the cheap

A browser mainstay for more than a decade, JavaScript has been gaining traction on the server side as of late, thanks to increasing developer interest in Node.js. This open source server-side framework allows Web developers to write event-driven JavaScript applications that run on Google’s open source V8 JavaScript engine.

No doubt, some of your developers are already experimenting with this tool. And while Node.js is still early in its adoption lifecycle, JavaScript’s transition from the browser to the server is sure to accelerate. After all, its prospects are impressive. Take Jackalope, for example. Built in less than 48 hours during the Joyent-sponsored Node.js knockout competition, Jackalope provides real-time Web statistics on mouse movements and clicks on a website, scaling alonside the number of users who visit a given Web page.

[ Find out which open source technologies won this year’s Best of Open Source Software Awards | Keep up with the latest open source trends and news in InfoWorld’s Technology: Open Source newsletter. ]

With Node.js recently gaining HP/Palm’s endorsement due to its inclusion in webOS 2.0, it’s high time to learn what to expect from Node.js and how to make the best use of it in the enterprise.

Empowering less experienced developers to build more scalable apps Node.js holds the promise of enabling less experienced, potentially lower-cost developers to create more scalable Web applications than they can build today with existing skill sets. Here, the framework’s asynchronous nature is key, as described on the Node.js website:

Thread-based networking is relatively inefficient and very difficult to use. … Node will show much better memory efficiency under high-loads than systems which allocate 2mb thread stacks for each connection. Furthermore, users of Node are free from worries of dead-locking the process — there are no locks. Almost no function in Node directly performs I/O, so the process never blocks. Because nothing blocks, less-than-expert programmers are able to develop fast systems.

The ubiquity of AJAX in the modern Web developer’s skill set provides a sufficiently large developer base from which to draw for the building of Node.js event-driven apps. Anyone who has been exposed to JavaScript programming at the presentation layer can now write server-side scripts, regardless of whether they are already familiar with PHP, Ruby, Python, Java, and the like.

In fact, this potential community of developers, as well as the community already growing around Node.js, was a key factor in HP/Palm’s decision to utilize Node.js in its webOS 2.0 platform. Dion Almaer, director of developer relations at Palm, explained in an email:

Node was an obvious choice for us. We had started to write a JavaScript service framework ourselves, but then Node came out with a great product and a great community. Rather than come out with our own system, we wanted to align behind something that was out there. We are webOS after all, and we’re always looking to align with the Web as a whole. We only innovate when there aren’t standards for us to work with (de facto or otherwise). The node team was also fantastic to work with, and really helped us as we transitioned it to a mobile form factor.

Reality check on scalability Any organization looking to leverage this pool of developers for server-side work via Node.js may, however, want to keep their scalability aspirations in check. Alex Payne, a developer at BankSimple, explains the technical challenges between, as he calls it, scaling in the small versus scaling in the large”:

The power of today’s hardware is such that, for example, you can build a web application that supports thousands of users using one of the slowest available programming languages, brutally inefficient datastore access and storage patterns, zero caching, no sensible distribution of work, no attention to locality, etc. etc. Basically, you can apply every available anti-pattern and still come out the other end with a workable system, simply because the hardware can move faster than your bad decision-making.

To further scale an application similar to what he describes above, Payne suggests merely selecting a technology with “slightly better” performance characteristics than what you are currently using. But for those organizations seeking significant scalability gains, as Payne explains, no single magic bullet technology will do the trick:

When you’re operating at scale, pushing the needle means a complex, coordinated dance of well-applied technologies, development techniques, statistical analyses, intra-organizational communication, judicious engineering management, speedy and reliable operationalization of hardware and software, vigilant monitoring, and so forth. Scaling is hard. So hard, in fact, that the ability to scale is a deep competitive advantage of the sort that you can’t simply go out and download, copy, purchase, or steal.

As such, Payne sees Node.js as a very attractive technology choice for developers dealing with “scaling in the small” scenarios. Other technologies such as Java or Scala, and a host of related architecture decisions, are better suited for operating at high scale in Payne’s opinion.

Node.js in the cloud A fairly large portion of in-house apps operate under the “small scale” scenario Payne describes above. Thus, for most organization, Node.js can, and should, find a place among your tools of choice.

However, it’s important to note that, outside of .Net, most modern enterprise Web apps are Java-based. Dynamic scripting languages haven’t crossed the mainstream enterprise chasm to any significant degree.

It’s certainly possible that Node.js, like other dynamic scripting languages before it, won’t play a major role in your data center, but it could still affect your IT operations, as many cloud service providers are eyeing its use. They are starting to see Node.js as an appropriate technology for Web apps that need the elastic scale characteristics a cloud provides.

Joyent, a startup that employs Node.js creator Ryan Dahl, and Heroku, a cloud service provider, both offer Node.js runtime environments in the cloud. And it wouldn’t be surprising to find Google supporting Node.js on Google App Engine someday soon, a move that may be accelerated depending on Google’s future strategy for the Java ecosystem.

Either way, by allowing less experienced developers to contribute more deeply to your IT portfolio, Node.js could be well worth the look.

Follow me on Twitter at SavioRodrigues. I should state: “The postings on this site are my own and don’t necessarily represent IBM’s positions, strategies, or opinions.”

This article, “JavaScript enters the server room with Node.js,” was originally published at InfoWorld.com. Read more of Rodrigues et al.’s Open Sources blog and follow the latest developments in open source at InfoWorld.com.