javascript 什么时候使用 node.js、sinatra 和 rails?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3730309/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
When to use node.js vs sinatra vs rails?
提问by donald
What are the best uses for these 3 languages/frameworks? Is it useful to mix all of them (or 2)?
这 3 种语言/框架的最佳用途是什么?混合所有这些(或 2 个)有用吗?
回答by tadman
If you're building a complete web application, you should probably use Rails as it provides the most comprehensive services. You can also leverage an enormous amount of work produced by the community.
如果您正在构建一个完整的 Web 应用程序,您可能应该使用 Rails,因为它提供了最全面的服务。您还可以利用社区产生的大量工作。
Sinatra is great for producing really thin, no-nonsense application services. You don't get much to work with, but it is very fast. If you need a database connection, you will have to add it in, and things like this can make creating even medium-sized applications a challenge. Basically if you need something very simple and don't need Rails, you probably need Sinatra.
Sinatra 非常适合制作非常精简、严肃的应用程序服务。你没有太多的工作,但它非常快。如果您需要一个数据库连接,则必须将其添加进来,这样的事情甚至可以使创建中等规模的应用程序成为一项挑战。基本上,如果您需要非常简单的东西并且不需要 Rails,那么您可能需要 Sinatra。
node.js is a great new framework for producing responsive, scalable applications, but it doesn't have nearly the library of add-ons that a mature platform like Rails does. node.js really excels at applications based on streaming and on-demand data transformation. Some of the examples produced in Node Knockoutare very interesting, but these were produced by some exceptional teams.
node.js 是一个伟大的新框架,用于生成响应式、可扩展的应用程序,但它几乎没有像 Rails 这样的成熟平台那样的附加组件库。node.js 确实擅长基于流和按需数据转换的应用程序。Node Knockout中生成的一些示例非常有趣,但这些示例是由一些出色的团队制作的。
While the Node Knockout entries are very well done, when compared to the sort of applications that were produced in the 2009 Rails Rumblethey seem to come across as toys lacking depth and complexity. This is not to discredit the work done by the Node Knockout teams, but it does show that the strengths of node.js are mostly to do with real-time events and less with conventional more ordinary DB-based apps.
虽然 Node Knockout 条目做得非常好,但与 2009 Rails Rumble中产生的应用程序类型相比,它们似乎是缺乏深度和复杂性的玩具。这并不是要诋毁 Node Knockout 团队所做的工作,但它确实表明 node.js 的优势主要与实时事件有关,而不是与传统的更普通的基于数据库的应用程序有关。
回答by Vidar
Use Rails if you're working for a client and need some fast cash. If you want to enjoy coding your app and keep maximum flexibility and app speed, use Sinatra. It's easy to build large applications with it, people who say otherwise haven't used it.
如果您正在为客户工作并且需要一些快速现金,请使用 Rails。如果您想享受编写应用程序并保持最大灵活性和应用程序速度的乐趣,请使用 Sinatra。用它构建大型应用程序很容易,否则说没有使用过它的人。
Node.js is more like Rack, which Rails and Sinatra is built on, and doesn't really compare. Express.js, which you can use on top of Node.js, is comparable to Sinatra, there might be other frameworks that compare to the bloated Rails stack, google it. If you like coding async Javascript, use Node.js. It's also faster than Sinatra and Rails, but coding in Ruby has it's advantages since you can use lots of really nice ruby gems which makes life easy.
Node.js 更像是 Rack,Rails 和 Sinatra 建立在 Rack 之上,并没有真正进行比较。Express.js 可以在 Node.js 之上使用,它可以与 Sinatra 相媲美,可能还有其他框架可以与臃肿的 Rails 堆栈相比,谷歌一下。如果您喜欢编写异步 Javascript,请使用 Node.js。它也比 Sinatra 和 Rails 快,但是用 Ruby 编码有它的优势,因为您可以使用许多非常好的 ruby gem,这使生活变得轻松。

