Node.js: A Beginner’s Perspective

I’d been curious about node.js for a while. Finding Twitter all atwitter about it at any particular moment isn’t difficult. People are experimenting with it and other JavaScript technologies, like WebSockets. Yahoo even showcased a multi-core HTTP server written in it a few months back. I already had a decent working knowledge of JavaScript. (If you don’t, check out Eloquent JavaScript or Crockford’s JavaScript to get up to speed.) So, I decided to poke my head in, see what all the hype was about, and share my experiences for any others considering doing the same. Here are my lessons learned.

Have at least a basic working knowledge of git. A significant number of node.js projects are hosted exclusively on github. While you can grab the source code by downloading an archive, it can make getting the latest updates tedious (compared to a few simple git commands) and makes it a lot more difficult to contribute back to those projects. Also, users of node.js and git seem to be of similar mindsets, so if you’re familiar with one community, chances are you’ll be comfortable in the other. There tends to be a good bit of overlap as well.

Look around for existing solutions. Don’t succumb to NIH Syndome, especially not just because of the project’s young age compared to some much older languages. The plethora of existing software written for it is pretty amazing. Good examples include the npm package management system, which can be very helpful in installing and distributing node.js packages, and nodeunit, a great simple unit testing framework. Regardless of what supporting library or tool you might need, you’ll probably find at least one option already available.

Seek out good resources. The project docs are pretty good. The community blog How to Node has lots of info on node.js topics. Follow the #nodejs Twitter hash tag or Delicious nodejs tag. Talk to others using node.js. It’s got a large and lively community of enthusiastic people doing cool cutting-edge stuff. For example, most non-library projects will probably need to be backed by a data source of some type. Whether you want to use MySQL or MongoDB, node.js can handle it. If you get stuck, post your query to the mailing list.

Don’t forget what language you’re using. While node.js hasn’t been around but a few years and isn’t a language in and of itself, JavaScript is very well-established and has plenty of existing libraries already available. node.js runs on V8, the same JavaScript engine that powers Google Chrome. If you can’t use your favorite library in node.js, there are probably already similar alternatives that people will readily suggest.

Most people know me as being a PHP developer. Don’t think this means that I’m abandoning it in favor of node.js. This was mostly just a small foray to explore another development platform. I’ll likely be keeping my eye on it, but it’s not likely to become my primary skillset anytime soon.

If you’ve used node.js, please post a comment. I’d love to hear about your own experiences and what resources you have to suggest for new users like me who are looking to get their hands dirty.

4 Comments

  1. Node is going to become a big part of the real-time web. I already use it for pushing updates from the server to clients in my Ruby on Rails applications. I’m also impressed by the express framework which builds a whole web application framework on top of node.js

    Definitely check out faye. http://faye.jcoglan.com/

  2. The IRC channel #node.js on irc.freenode.org, Howtonode.org and I believe there is a nettuts article as well.

    Node.js is a great platform to write applications on and it streches further than just web servers. There are projects from GUI (ncurses and gtk) to OpenGL integration and everything in between. It is evented which makes it a great choice for anything that requires you to deal with IO of any sort.

    I’d recommend diving further than just a surface level view. You’ll want to abandon php. ;D

  3. Timothy says:

    You’re one step ahead of me! :) I’ve been thinking about exploring node.js, too. I think there’s great potential for server-side JavaScript but I think the communities and implementations are still too fragmented overall to achieve critical mass. Still, it’d probably not be a bad to have in my skill set! And thanks for highlighting a few tools too, like npm and nodeunit.

  4. Hi Matthew,

    You wrote a great beginner perspective. I’ve been using nodejs for a while and I’m realy excited. Please check out my website http://nodecasts.org It’s new, with only one episode, but next week I’ll release the second.

    Cheers,

    Emerson Macedo
    http://nodecasts.org
    http://codificando.com