문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top