Oliver Nassar

node.js: first impressions..

November 09, 2010

Updated code (if you only care about the install process, just follow these lines):

cd
sudo apt-get install -y g++ curl libssl-dev apache2-utils
wget http://nodejs.org/dist/node-v0.2.6.tar.gz
gunzip node-v0.2.6.tar.gz
tar -xf node-v0.2.6.tar
cd node-v0.2.6/
./configure
make
sudo make install
cd ..
rm node-v0.2.6.tar
rm -r node-v0.2.6/

All this talk about node.js lately (apparently based off of something called CommonJS.. news to me..) made me realize I'm becoming a dinosaur. Here's how I installed node.js, my limited understanding of what it is and what it's useful for, and a good post to read to get a solid tutorial.

I'm installing this on an Ubuntu 10.10 box whereby I'm running a standard LAMP stack. Here's the code I ran from my terminal:

cd
sudo apt-get install -y g++ curl libssl-dev apache2-utils
wget http://nodejs.org/dist/node-v0.2.4.tar.gz
gunzip node-v0.2.4.tar.gz
tar -xf node-v0.2.4.tar
cd node-v0.2.4/
./configure
make
sudo make install
cd ..
rm node-v0.2.4.tar
rm -rf node-v0.2.4/

In short, it installs the necessary tools (compiler, curler, apache tools), grabs the source, unzip/untars it, makes it, and then removes the install files. Easy enough.

This got me far enough to actually hit up some code. I found this node.js tutorial which does a great job explaining what node.js is, how it's useful, and walking you through some straight forward examples.

So what exactly is node.js? I'm a little confused myself at this point, but here's what I do get. It's an application that allows a machine to process JS code server-side. You can literally write JS code in the same syntax and formality as you've been writing it before, and your server will be able to compile/interpret it.

The power of this comes in two ways as I see it. Less overhead for a front-end engineer to create a fully-functional web server (both client/server sides, that is). But most likely more important would be the fact that it's an evented I/O framework (disclaimer: took that line right from node.js's wikipedia page). This allows one to write code that performs heavier tasks without having to worry about threading, processes and the like (read: JS-style callbacks after function/method calls).

The problem with this for me? I don't know enough bout that stuff to comment on it, so I can't really say how good it might be. I'll keep playing with it and see if I can get some cool demos up to see what kind of limits it's got, and update this post afterwards.

But so far, I'm not overly impressed. Not that it's not an advanced technical implementation, but rather I can't see just yet how I would use this in a way that I gained much benefit. I'll probably be eating those words in a few months though. We'll see.

Updates

Some good follow up reading material:
What is Node.js - Evented and Non-blocking I/O JavaScript - Beakkon
Why Developers Should Pay Attention to Node.js