in late 2011 I started experimenting with Node.js, and after signficant contemplation I’ve decided to make the leap and use it as my new primary platform. I thought I’d write this blog post to explain how and why I’m doing that.
*note: due to length, I’m splitting this article into three pieces, part one about how is available, stay tuned for the final note!
First, let’s discuss the why.
Then there’s the features. The event model commonly used in the Node community and the speedy V8 engine make for fast apps. Socket.io is a killer feature that enables real-time communication between the server and the client without requiring the browser to request anything. The server can push out new data on demand. And the Connect framework enables every project to have a built-in web server so that you don’t have to install tools like MAMP or XAMP on your workstation.
And the final, and probably least obvious reason, is the trend curve of new technology. When a new technology arrives on the scene people start to talk about it. A few brave souls will try it out. If it has merit, it will gain buzz. Then it progresses into mainstream, when adoption becomes easy and many people begin to use it. After some time it enters a mature phase where it isn’t really cool anymore, but it pays the bills and it becomes “enterprise” (or maybe just dies a quiet death).
Ruby on Rails has ridden the trend curve for an exceptionally long time, but it is well into the “mature” part of the curve. I like Rails a lot but jumping into it now feels like becoming a fan of the sports team that won the last three championships.
Node.js is still at the early buzz stage. I think, and I’m willing to bet on it, that it has a long run left ahead of it. And considering the first two points above, I think it’s a great fit for me. Already, with frameworks like npm and Express, the barrier to adoption is shrinking.
This would be an awesome segue into the “how” I transitioned, but first I have to answer the two obvious questions you have.
Why not continue to use Django? I feel that Django is stuck, becoming a niche product targeted at CMS solutions and old-school websites where you click a link and the page refreshes. The developers have handily avoided incorporating features that will help modern web developers create cutting edge apps. For example, unless you have an add-on module there is no RESTful API support in Django. It is a great product but it really isn’t any different now, feature wise, than it was in 2007.
What are the short-comings of Node.js? One of the biggest is the relative immaturity of key modules. There are many examples where multiple do the same thing. Fortunately, the ecosystem is starting to settle and a few key projects are emerging and amassing strong communities. Another is that there are still some deployment challenges. For example, how do you deploy an Express + Socket.io server in a load-balanced configuration? It is possible, but it’s not documented well (though the Nginx 1.3 release in February does pave the way for improvements). Basically, it boils down to the fact that it’s new, but that’s also what makes it so fun.
This post is long enough, stay tuned for two follow up articles where I discuss how I made the switch and some comparisons between Node.js and other tools I’ve used. * Note: Here is the next one: How I switched to Node.js