Sunday, August 22, 2010

My First Day With Node.js

Today I spent a good number of hours playing with node.js the hip new concurrent evented javascript server that runs on Google's V8 javascript server.

I've been meaning to play with it for a while given its recent popularity and a couple of weeks ago I casually committed to taking part in the Node Knockout(a node.js event inspired by the Rails Rumble) next weekend. Competitions like this are a good way for me to convince myself to learn new stuff and they're fun. The first Rails project I spent a decent amount of time thinking about was for the Rails Rumble a couple of years ago.

So far playing with node has been quite entertaining. I've managed to set up a tcp/ip server running chat and some minor interactiveness in a few hours, with most of those hours having been taking up with upgrading my javascript skills to deal with more complex things than some fancy browser manipulation. I haven't done any serious load testing but it performed well and took up minimal resources under my very basic attempt at hitting it with a few users trying to spam each other.

One of the big issues I initially had was getting stuff to split into separate files nicely instead of massive scripts running the entire system. But that turned out to be relatively straight forward to fix once I got a better idea of what was going where and a handle on module system that node provides.

My biggest rant about node and to a certain degree JavaScript so far today has been the lack of sensibly descriptive naming in a lot of the code floating around. It certainly didn't help my initial understanding that the example chat app had server.js and fu.js with the server initialization occurring fu.js. It reminds me how much I love that the Ruby community has favoured very descriptive names for things.

So far I've enjoyed the change in headspace as well as doing some "serious" programming with JavaScript for a change. I certainly think most people will find their Javascript skills will improve from spending some time with node.js. Hopefully a couple more evenings and I'll have learned enough to not completely embarrass myself during the node knockout. At least there's not going to be any insane last minute problems getting the server setup right.

No comments: