Derek Williams

Menu

Node.js

A lingering sense of abandonment dating back to Netscape’s LiveWire leaves me leery of server-side JavaScript (SSJS). Not that it’s a bad idea, it just didn’t gain traction. JavaScript as a language is great but, by design, it lacks built-in I/O support and other things required for writing servers. And with no standard platform to fill these holes, JavaScript remained relegated to sandboxes, mainly browers and system extensions.

That’s all been changing as SSJS proponents have rallied around Node.js, a toolkit for easily building scalable event-driven servers running atop Google’s V8 JavaScript Engine. It was easy to ignore Node’s initial hype, but when I found myself needing to serve up some new REST APIs, I thought I’d check it out. Besides, my AJAX calls can point anywhere, so there was really no risk in trying. If it didn’t work out, I could always abandon Node and fall back to something more conventional, maybe even EventMachine.

Getting started was quick and easy. Cloning and building takes only a few minutes; even faster, binaries are just a sudo apt-get install away. There are many online tutorials, so I worked through the obligatory web server and other examples. There’s not a lot going on in my services, so I couldn’t factor them into many event-driven/parallel fragments. But I quickly got a feel for doing things the Node way: spinning off handlers, writing callbacks, and even running multiple node processes. With help from Node’s non-blocking libraries, that single-threaded event loop wasn’t a bottleneck.

It didn’t take long to complete my work, so I quickly got to the question of deployment. Sure, I have VMs out there where I can run whatever I want, but I needed this running under my jailed hosting service. The awesome Heroku service now supports Node, but I stopped short of rolling it out there. So I’m keeping it local now as I build out the other pieces.

Node has come a long way fast and appears to have a bright future. It has a rich and growing ecosystem of basic modules and frameworks for web apps/MVC, content management, blogs, comet, etc. Time will tell how pervasive Node becomes, but for shops wanting JavaScript all the way down, it’s a very nice platform choice.