Why node.js

I’ve moved from Python to Javascript on the server side – specifically, Tornado to Node.js.

Three years ago, I moved from Perl to Python because I got free hosting at AppEngine. Python’s a cleaner language, but that was not enough to make me move. Free hosting was.

Initially, my apps were on AppEngine, but that wouldn’t work for corporate apps, so I tried Django. IMHO, Django’s too bulky, has too much “magic”, and templates are restrictive. Then I tried Tornado: small; independent modules; easy to learn. I used it for almost 2 years.

The unexpected bonus with Tornado was it’s event-based model: it wouldn’t wait for file or HTTP requests to be complete before serving the next request. I ended up getting a fair bit of performance from a single server.

Trouble is, Python’s a rare skill. I tried selling Python in corporates a couple of times, and barring RBS (which used it before I came in, and made it really easy for me to build an IRR calculator), I’ve failed every time. Apart from general fear, uncertainty and doubt, getting people is tougher.

Javascript’s a good choice. It has many of Python’s benefits. It’s easy to recruit people. Corporates aren’t terrified of it. Rhino was good enough a server. All it lacked was the “cool” factor, which node.js has now brought it. And besides,

  • It’s fast. About 20 times faster than Rhino, by my crude benchmarks.
  • It’s stable. (Well, at least, it feels stable. Rock solid stable. Sort of like nginx.)
  • It’s asynchronous. So I don’t miss Tornado
  • It has a pretty good set of libraries, thanks to everyone jumping on to it
  • I can write code that works on the client and server – e.g. form validation

Bye, Python.

8 thoughts on “Why node.js”

  1. Very interesting post. I’d be keen to learn which stack of libraries and frameworks you end up using on top of node.js and your experiences with them. Also, what are your experiences so far of using node.js in a production setting and how do they compare with, for example, deploying Python code in Tornado?

  2. Javascript, as Doug Crockford said, is a misunderstood language. I was under the impression that enterprises are quite wary about server side javascript. I am quite surprised to learn that companies are more open to Javascript than Python (given that Google embraces Python). Also, in India, developers look at javascript more as a UI-bells-and-whistles stuff and it is quite difficult to hire a Quality serverside js developer. Anyway … for rapid prototyping isn’t Python good enough ? You are anyway used to the quirks of Django etc for 3 yrs. Am sure node.js would be having some baggage elsewhere. Or is it the case that change is the only constant ?

  3. If you like the benefits of JavaScript and node.js but you still miss python’s syntax and productivity, you may want to play with Coffeescript. Check it out, it’s addictive…

  4. Yes, I did play with it. It’s amazing. I’m waiting for a few more months, allowing it to get more popular, and once someone else on my team suggests it independently, we’ll jump into it!

Leave a Comment

Your email address will not be published. Required fields are marked *