holy crap, it's Node.js.


I got into Rails in the late summer of 2006. It was a pretty wild ride: Rails 2.0 was still over a year away, Github didn’t exist, we were installing plugins (not gems) by finding them on technoweenie’s SVN repository, and best practices/libraries hadn’t really congealed yet. Everybody was more or less making their own way. This was somewhat restrictive, in the sense that we didn’t have the same communication tools, documentation resources, and software libraries we have today; but also extremely productive, as it forced the community to come up with creative solutions that would build on top of each other and create a best of breed. This is standard in any evolutionary process, and Node.js proves to be no exception.

Node.js is in a similar state at the moment, where best practices, documentation resources, and best-of-breed software libraries are still congealing, and at an extremely rapid pace. The community has plenty of really creative and intelligent thinkers who are writing some great code. The Node.js revolution may have a leg or two up on the Rails revolution, however. For one, it can draw upon the wide array of JavaScript programmers who have a decade or more of experience. For another, I think the Node community has been able to learn from the Rails community (of which there will surely be some overlap) about coding practices, deployment practices, and what it means to develop for a niche web platform.

I’ve been playing with my own Node.js app for a few days, and I’ve learned a few things. Number 1, everything you heard about code reuse between the server and the client is true. Using browserify, I was able to expose some server-side CoffeeScript as client-side JavaScript without having to have to do too much. Very cool. Number 2, library development is going quickly, and a lot of it is being sponsored. Whereas Rails was presented as a full stack and Rack only came after other Ruby frameworks started to pop up, Node.js is pretty low-level, and is being added to from the ground up. Sencha Labs (perhaps best known for Sencha Touch) sponsored Tim Caswell and TJ Holowaychuk to create the connect middleware, and Holowaychuk is taking this further with Express, which is Node’s equivalent of Sinatra. LearnBoost has sponsored Guillermo Rauch to create Socket.io socket transport layer, on top of which DNode and Juggernaut can build RPC and pubsub libraries. (Even these libraries, as well as Express, have formed as a base for other libraries to be built on top.)

Just as Rails was to me 5 years ago, Node.js is providing an exciting landscape.### but what am I doing with Node? Well, I’m glad you asked. A friend of mine once taught me this Chess variation called Kriegspiel, where you can see your pieces but not those of your opponent’s. Through trial and error, you have to build an understanding of where your opponent’s pieces are, while they’re trying to do the same regarding your pieces. It’s a very challenging game, and I thought it’d be a great experiment for Node’s asynchronous nature. Also, my friend has been living overseas for the past few years, so it’s probably the only way we’d actually be able to play again. Enter Kriegspiel.js.

kriegspiel screenshot

There are a few problems with the game right now… for one, you actually see both white and black pieces, and for another, it doesn’t actually work. But most of the pieces behave properly, and most of the captures work appropriately. Check, mate, en passant, and castling rules haven’t been implemented yet. But it’s coming along. And maybe one day you’ll be playing a game. Go ahead and try it out.

comments powered by Disqus