1

I have an app that I'm building which very much works like craigslist but with limited functionality. I generally would use Rails for this kind of app but I'm interested in learning nodejs/backbonejs framework and it seems like this is a good opportunity to pick it up.

I'm not sure how nodejs and/or backbonejs fits in this solution? I don't necessarily have to use rails, I'm fine with using nodejs and backbonejs if that makes sense.

Thanks

ed1t
  • 8,719
  • 17
  • 67
  • 110

1 Answers1

6

You certainly can use Node.js or Rails or both with Backbone.js - I have used stacks with all or combinations of these technologies and they are great. Picking which ones to use should depend on what you are building and to a lesser extent, your comfort levels with each technology.

Replacing Rails with Node
Node.js can easily replace the functionality of Rails, i.e. talking to the database, containing model logic, serving pages and assets and controlling routing. There are tons of tons of modules available for this. A common solution is to use Express(a simple Sinatra type web framework) to serve pages and handle templating and an ODM/ORM to handle database objects. There are also more extensive rails-like frameworks such as Geddy.

My take on Node as a direct replacement for Rails
If you simply want the functionality of Rails, use Rails. Ruby/Rails code looks cleaner and is more managable in my opinion and it is a bit more mature (feel free to flame...). If you are serving a lot of different pages, Rails does a good job of organizing things. However, if you are making a single page app, which is one of the main use cases for Backbone, then much of the Rails package is unnecessary - you just need the model logic and database interaction. In this case, something like Express(Node) or Sinatra(Ruby) with an ORM and RESTful routing for communicating between back and front end will sufice.

Added functionality with Node
The more compelling use cases for Node are for sites with real time or multiplayer aspects; Node is great for concurrency and asynchronousity. Use Node if you have clients sending data to each other without reloading pages or data being pushed from server to client without another page load (a great module for doing this is Socket.io). Again, this is a use case that works well with single page or high interaction interfaces that Backbone caters to.

cmpolis
  • 3,051
  • 21
  • 19
  • So let's say for my example - a web app whicb functions like Craigslist, would you consider that as a real time app and would you use nodejs and backbone instead of rails? – ed1t Nov 29 '11 at 12:12
  • Nice overview. ed1t: I don't see anything especially real time-y about a craigslist-like site. It's mainly a data management problem, rather than a UI problem, unless you've got an original take on it. – maxl0rd Nov 29 '11 at 14:59
  • @ed1t Yeah, you could use node to push out updates such as new listings to clients (instead of polling). For the standard CRUD stuff - you could use Rails or Node, it's all in my answer... – cmpolis Nov 29 '11 at 18:42