有人能给我一个node.js应用程序的例子吗
我试图了解现有的一些较新的 Web 编程框架(即 Node.js、Rails 和 Sinatra)之间的差异。
有人能给我一个最适合每个框架的应用程序示例吗?
也就是说,什么是最适合 Node.js 而不是 Rails 或 Sinatra 的应用程序,什么是最适合 Rails 而不是 Node.js 和 Sinatra 等的应用程序......
I'm trying to understand the differences between some of the newer web programming frameworks that now exists, namely Node.js, Rails, and Sinatra.
Could someone give me an example of applications that would work best on each of the frameworks?
That is to say, what is an application that would be best suited for Node.js as opposed to Rails or Sinatra and what is an application that is best suited for Rails as opposed to Node.js and Sinatra etc.....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Sinatra 和 Rails 都是 Web 框架。它们提供了常见的 Web 开发抽象,例如路由、模板、文件服务等。node.js
非常不同。从本质上讲,node.js 是 V8 和事件库以及面向事件的标准库的组合。与 Ruby 的 EventMachine 相比,node.js 更好。
例如,这是一个使用 EventMachine 的基于事件的 HTTP 服务器:
这是一个 node.js 示例:
这种方法的好处是服务器不会阻塞每个请求(它们可以并行处理)!
node.js 拥有整个围绕事件概念构建的标准库,这意味着它更适合任何问题即 I/O 限制。一个很好的例子是聊天应用程序。
Sinatra 和 Rails 都是非常精致、稳定且流行的 Web 框架。 Node.js 有一些 Web 框架,但目前没有一个达到其中任何一个的质量。
在众多选择中,如果我需要更稳定的 Web 应用程序,我会选择 Sinatra 或 Rails。如果我需要更高可扩展性和/或多样化的东西,我会选择node.js
Sinatra and Rails are both web frameworks. They provide common web development abstractions, such as routing, templating, file serving, etc.
node.js is very different. At it's core, node.js is a combination of V8 and event libraries, along with an event-oriented standard library. node.js is better compared to EventMachine for Ruby.
For example, here's an event-based HTTP server, using EventMachine:
And here's a node.js example:
The benefit of this approach is that the server doesn't block on each request (they can be processed in parallel)!
node.js has its whole standard library built around the concept of events meaning that it's much better suited to any problem that is I/O bound. A good example would be a chat application.
Sinatra and Rails are both very refined, stable and popular web frameworks. node.js has a few web frameworks but none of them are at the quality of either of those at the moment.
Out of the choices, if I needed a more stable web application, I'd go for either Sinatra or Rails. If I needed something more highly scalable and/or diverse, I'd go for node.js