Node.js, Rails, and webapp development

Posted on September 27, 2011

Last updated on February 28, 2013

I have recently tried to code up a web-app using Node.js / MongoDB, and that adventure ended up rather unsuccessfully, after I decided that Node.js, while very cool, should not be the tool of choice if all you want to do is develop a standard web-app that doesn’t involve things such as high concurrency, or real time data flow between client and server. I have now started learning Ruby and the Ruby on Rails framework, and I don’t understand why I haven’t started using RoR earlier - it’s actually quite nice!

Now, I do not mean to say that Node.js is not an awesome web-server, it is, and I have got to know it quite well. My first adventure into Node.js was a multiplayer space game where you can fly a ship, go onto planets, and trade resources. Here is a screenshot:

It’s so awesome!

It’s so awesome!

Well, that took a couple thousand lines of code, and Node.js was a really good choice for it. Real-time bidirectional communications channel makes it very easy to send and receive messages about ship position, ship movement, etc. If you would like to read more about how I implemented the game, here is a pdf which goes into the details. The whole git repository is obtainable here.

After my successful usage of Node.js to make a multiplayer webgame, I decided it would be a good idea to use it for more standard web-app development that doesn’t call for real-time concurrency. That didn’t end up so well. I have spent considerable time doing things not directly related to the app, that took away time from proper app development. Here are some things that took lots of time…

1 Ruby and Rails

After spaghetting myself in callbacks and spending way too much time modifying not-working Node packages, I ventured into Ruby and Ruby on Rails.

I have just started learning Ruby and RoR yesterday, and have already (!) managed to get a simple application working with Twitter authentication. Rails makes everything so simple, and I shiver when I look back at the hacky Coffeescript Node code, which is most likely filled with security holes.

Possibly this is just beginner’s excitement (I had the same when I started using Node after having made sites in PHP), but for now I am very pleasantly surprised by Rails, and by the fact I somehow never managed to use it before.

2 Conclusion

Node.js is awesome for one-page web-apps that require concurrency and real-time interaction, for example games. Or just have a look at this years Nodeknockout for some excellent examples of uses for Node! But please, do not try and use it when developing a web-app with many subpages, many models, and all that other stuff.

Additionally, I think I’m back to using more ‘earthly’ technologies. All the hype about Node and NoSQL made me get myself into technology that’s very new and still quite buggy. Though MongoDB is actually quite cool, it has awesome functionality such as geospatial indexing, and I’m sure I’ll be back to using it at one point!

Anyways, now I’m back to playing around with Ruby on Rails!

Markdown SHA1: 52c930cba3b1e0397fd0a9a4a1a5adb8caf7ba72