为什么以及何时使用Node.js? [英] Why and when to use Node.js?

查看:103
本文介绍了为什么以及何时使用Node.js?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何决定何时使用Node.js?

Possible Duplicate:
How to decide when to use Node.js?

对不起,如果我有点模棱两可,但是我试图理解使用 Node.js 而不是其他服务器端语言.

Sorry if I'm a bit ambiguous, but I'm trying to understand the real advantages of using Node.js instead of other server-side language.

我是JavaScript爱好者,所以我可能会玩Node.js,但我想知道是否应该在项目中使用它.

I'm a JavaScript enthusiast, so I'm probably going to play with Node.js, but I want to know if I should use it in my projects.

推荐答案

发生异步非阻塞 I/O 构建在 V8 的之上.

It's evented asynchronous non-blocking I/O build ontop of V8.

因此,我们获得了V8的所有性能提升,这是Google JavaScript解释器.由于JavaScript性能竞赛尚未结束,您可以期望Google不断更新V8上的性能(免费).

So we have all the performance gain of V8 which is the Google JavaScript interpreter. Since the JavaScript performance race hasn't ended yet, you can expect Google to constantly update performance on V8 (for free).

我们有无阻塞的I/O,这只是进行I/O的正确方法.这基于事件循环,并为您的I/O使用异步回调.

We have non-blocking I/O which is simply the correct way to do I/O. This is based on an event loop and using asynchronous callbacks for your I/O.

它为您提供了有用的工具,例如创建HTTP服务器,创建 TCP 服务器,处理文件I/O.

It gives you useful tools like creating a HTTP server, creating a TCP server, handling file I/O.

这是一个低水平的高性能平台,可以执行任何类型的I/O,而无需从头开始用C编写整个过程.由于无阻塞的I/O,它的扩展性非常好.

It's a low level highly performant platform for doing any kind of I/O without having to write the entire thing in C from scratch. And it scales very well due to the non-blocking I/O.

因此,如果您想使用无阻塞I/O编写高度可扩展且高效的应用程序,同时又要使用高级脚本语言,则希望使用Node.js.如果需要,您可以通过用C编写扩展来手动优化部分代码.

So you want to use Node.js if you want to write highly scaling and efficient applications using non-blocking I/O whilst still having a high level scripting language available. If needed, you can hand optimise parts of your code by writing extensions in C.

有大量的Node.js操作系统库可以为您提供抽象,例如 Express.js 立即.

There are plenty of OS libraries for Node.js that will give you abstractions, like Express.js and now.

如果希望(慢速)高级抽象为您做所有事情,则不想使用Node.js.如果您想要 RAD ,则不想使用Node.js.如果您无法负担起一个年轻的平台,则不想使用Node.js,这可能是由于必须自己编写大量代码来完成内置在其他框架中的事情,或者是因为您不能使用Node .js,因为该API尚不稳定,或者它是Sub 1.0以下版本.

You don't want to use Node.js if you want (slow) high level abstractions to do everything for you. You don't want to use Node.js if you want RAD. You don't want to use Node.js if you can't afford to trust a young platform, either due to having to write large pieces of code yourself to do things that are build into other frameworks or because you can't use Node.js, because the API isn't stable yet or it's a sub 1.0 release.

这篇关于为什么以及何时使用Node.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆