与其他 Web 技术相比,node.js 的优势
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6484175/
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
Advantages of node.js in comparison with other web technologies
提问by Michael
As I understand, node.jsis useful for Java Script programmers, who can now develop in server-side. Besides, some Java Script code can be ported from client-side to server-side.
据我了解,node.js这对 Java Script 程序员很有用,他们现在可以在服务器端进行开发。此外,一些Java Script 代码可以从客户端移植到服务器端。
Are there any other advantages for node.jsin comparison with other server-side technologies (Java web frameworks, RoR, Django, etc.) ?
node.js与其他服务器端技术(Java Web 框架RoR、Django、 等)相比,还有其他优势吗?
回答by Alfred
Package management
包管理
Compared to Java's Mavennode.js package management system(npm) is the best ever. To me that alone should be enough to switch. The packages I recommend you to check out:
与 Java 的Mavennode.js 包管理系统 ( npm) 相比,它是有史以来最好的。对我来说,仅此一点就足以切换。我建议您查看的软件包:
- express
- socket.io
- node_redis
- mongoose
- everyauth
- 表达
- socket.io
- node_redis
- 猫鼬
- 每次验证
You can search for packages using http://search.npmjs.org/
您可以使用http://search.npmjs.org/搜索包
Fast
快速地
node.js is very fast(event-loop non-blocking) and also has very speedy native bindings(C). For example node_redis(C binding) benchmarks:
node.js 非常快(事件循环非阻塞)并且还具有非常快的本地绑定(C)。例如 node_redis(C binding) 基准测试:
PING: 20000 ops 46189.38 ops/sec 1/4/1.082
SET: 20000 ops 41237.11 ops/sec 0/6/1.210
GET: 20000 ops 39682.54 ops/sec 1/7/1.257
INCR: 20000 ops 40080.16 ops/sec 0/8/1.242
LPUSH: 20000 ops 41152.26 ops/sec 0/3/1.212
LRANGE (10 elements): 20000 ops 36563.07 ops/sec 1/8/1.363
LRANGE (100 elements): 20000 ops 21834.06 ops/sec 0/9/2.287
Active development/community
积极的发展/社区
Ryan Dahl is working very very hard on his project. Also node.js now has active support(sponsor) from for example Joyent. The community is growing rapidly
Ryan Dahl 在他的项目上非常努力。node.js 现在也有来自例如 Joyent 的积极支持(赞助商)。社区发展迅速
回答by rcode
Performance is the main advantage, node.js allocates a small heap per each connection, while other server side solutions create a (2MB) thread for each incoming connection, and of course creating a thread is much slower than allocating heap memory. Among the other advantages is the event-oriented and non-blocking nature of node.js.
性能是主要优势,node.js 为每个连接分配一个小堆,而其他服务器端解决方案为每个传入连接创建一个(2MB)线程,当然创建线程比分配堆内存慢得多。其他优点之一是 node.js 的面向事件和非阻塞性质。
回答by bmatheny
node.jsis event driven. While most other frameworks have this kind of functionality built-in as an add-on (e.g. via event machine), this is just "the way" in node.js. The thought is that an event driven architecture can lead to more scalable applications (often motivated by The C10K problem). Second, being written in JavaScript lowers the barrier to entry for most front-end developers who are already used to working with the language. In my opinion it's also pretty fun to work with, but I can't say I've deployed it for any high traffic applications. It also has the hype machine going for it. Recently I have become enamored with liftand scalabut that's just my own preference.
node.js是事件驱动的。虽然大多数其他框架都将这种功能作为插件内置(例如通过事件机),但这只是node.js. 这个想法是事件驱动的架构可以导致更具可扩展性的应用程序(通常由C10K 问题驱动)。其次,使用 JavaScript 编写降低了大多数已经习惯使用该语言的前端开发人员的入门门槛。在我看来,使用它也很有趣,但我不能说我已经为任何高流量应用程序部署了它。它也有炒作机器。最近我迷上了lift和scala,但这只是我自己的喜好。
回答by Michael Draper
As application developers it is our responsibility to Apply logic to solve problems. All problems that front-end developers have have similar counterparts in back-end development. Yes they are expressed differently, but they are fundamentally the same problems.
作为应用程序开发人员,我们有责任应用逻辑来解决问题。前端开发人员遇到的所有问题在后端开发中都有类似的对应物。是的,它们的表达方式不同,但它们基本上是相同的问题。
Node simply expresses this fact by unifying the methodologies in a discrete and rational way.
Node 通过以离散和理性的方式统一方法论来简单地表达这一事实。
By having the back-end written in the same way, applying the samelogical paths, it makes the transition far more transparent to the developer, simplifying their work
通过以相同的方式编写后端,应用相同的逻辑路径,它使转换对开发人员更加透明,简化了他们的工作

