javascript Node.js 与 Twisted 的用例是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3461549/
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
What are the use cases of Node.js vs Twisted?
提问by pmn
Assuming a team of developers are equally comfortable with writing Javascript on the server side as they are with Python & Twisted, when is Node.js going to be more appropriate than Twisted (and vice versa)?
假设一组开发人员对在服务器端编写 Javascript 和使用 Python 和 Twisted 一样舒服,那么 Node.js 什么时候比 Twisted 更合适(反之亦然)?
回答by Alex Martelli
Twisted is more mature -- it's been around for a long, long time, and has so many bells and whistles as to make your head spin (implementations of the fanciest protocols, integration of the reactor with a large variety of other event loops, and so forth).
Twisted 更成熟——它已经存在了很长时间,并且有很多花里胡哨的东西让你头晕目眩(最奇特的协议的实现,反应堆与各种其他事件循环的集成,以及等等)。
Node.js is said to be faster (I have not measured it myself) and might perhaps be simpler to use (if you need none of the extra bells and whistles) exactly because those extras aren't there (kind of like Tornado in the Python world -- again, I have never measured relative performance).
据说 Node.js 更快(我自己没有测量过)并且可能更易于使用(如果你不需要额外的花里胡哨),正是因为这些额外功能不存在(有点像 Tornado 中的Python 世界——同样,我从未测量过相对性能)。
So, I'd absolutely use Twisted if I needed any of its extra features or wanted to feel on a more solid ground by using a more mature package. If these considerations don't apply, but top performance is a key goal of the project, then I'd write a simple benchmark (but still representative of at least one or two key performance-need situations for my actual project) in Twisted, Node.js, andTornado, and do a lot of careful measurement before I decide which way to go overall. "Extra features" (third party extensions and standard library) for Python vs server-side Javascript are also much more abundant, and that might be a key factor if any such extras are needed for the project.
因此,如果我需要 Twisted 的任何额外功能,或者想通过使用更成熟的包来感受更坚实的基础,我绝对会使用 Twisted。如果这些考虑因素不适用,但最高性能是项目的关键目标,那么我会在 Twisted 中编写一个简单的基准测试(但仍然代表我的实际项目中至少一两个关键性能需求情况), Node.js和Tornado,并在我决定总体走哪条路之前做了很多仔细的测量。Python 与服务器端 Javascript 的“额外功能”(第三方扩展和标准库)也更加丰富,如果项目需要任何此类额外功能,这可能是一个关键因素。
Finally, if none of these issues matter to a specific application scenario, have the development team vote on relative simplicity of the three candidates (Twisted, Node.js, Tornado) in terms of simplicity and familiarity -- any of them will probably be just fine, might as well pick whatever most of the team is most comfortable with!
最后,如果这些问题对特定应用场景都不重要,请让开发团队在简单性和熟悉度方面对三个候选者(Twisted、Node.js、Tornado)的相对简单性进行投票——它们中的任何一个都可能只是好吧,不如选择团队中大多数人最舒服的方式!
回答by Amir Ali Akbari
As of 2012, Node.js has proved to be a fast, scalable, mature, and widely used platform. Ryan Dahl, creator of Node.js quotes:
截至 2012 年,Node.js 已被证明是一个快速、可扩展、成熟且广泛使用的平台。Node.js 的创建者 Ryan Dahl 引用:
These days, Node is being used by a large number of startups and established companies around the world, from Voxer and Uber to Walmart and Microsoft. It's safe to say that billions of requests are passing through Node every day. As more and more people come to the project, the available third-party modules and extensions grow and increase in quality. Although I was once reserved about recommending it for mission-critical applications, I now heartily recommend Node for even the most demanding server systems.
如今,世界各地的大量初创公司和老牌公司都在使用 Node,从 Voxer 和 Uber 到沃尔玛和微软。可以肯定地说,每天有数十亿个请求通过 Node。随着越来越多的人加入该项目,可用的第三方模块和扩展也在不断增长并提高质量。虽然我曾经对推荐它用于任务关键型应用程序持保留态度,但现在我衷心推荐 Node 用于即使是最苛刻的服务器系统。
More formally, the advantages of Node can be classified as:
更正式地说,Node 的优势可以归类为:
Great community:It can be said that no other platform gained such community appeal in such a short period of time, it has hundreds of contributors and thousands of watchers in GitHub, and is being used by giants like Yahoo! (Manhattan project), e-bay, LinkedIn, Microsoft, and Voxer.
NPM:Although having a relatively small core, Node has lotsof packages available to extends its functionality to anything you may consider! Its all automated and being developed and extended actively, think of PyPI (pip).
Scalability and Speed:Node's architecture and single threaded nature allows high scalability and speed. Specially after 0.8 release, its speed got really faster (benchmarks), which can be confirmed by a lot of large businesses using Node. The V8 core of it is also constantly getting better thanks to the current browser war.
JavaScript:The core language of Node (JS) fits better for such server side usages, specially lambda functions, dynamic objects, and easy JSON serialization are JS highlights which really fits well in cases that speed and scalability counts. (Python has all of them but these are really better and more powerful in JS).
Deployment:Because of its wide usage, a lot of really good sites provide tools for easy and powerful Node deployment, including: Heroku, Joyent, Cloud9 and a lot more.
伟大的社区:可以说没有其他平台在如此短的时间内获得如此大的社区吸引力,它在 GitHub 上拥有数百名贡献者和数千名观察者,并被 Yahoo! 等巨头使用。(曼哈顿项目)、e-bay、LinkedIn、微软和 Voxer。
NPM:虽然 Node 的内核相对较小,但它有很多可用的包可以将其功能扩展到您可能考虑的任何事情!想想 PyPI (pip),它都是自动化的,并且正在积极地开发和扩展。
可扩展性和速度:Node 的架构和单线程特性允许高可扩展性和速度。特别是在 0.8 发布之后,它的速度真的变快了(benchmarks),这可以得到很多使用 Node.js 的大型企业的证实。由于当前的浏览器War,它的 V8 核心也在不断地变得更好。
JavaScript:Node (JS) 的核心语言更适合这样的服务器端使用,特别是 lambda 函数、动态对象和简单的 JSON 序列化是 JS 的亮点,非常适合速度和可扩展性很重要的情况。(Python 拥有所有这些,但这些在 JS 中确实更好更强大)。
部署:由于它的广泛使用,很多非常好的站点都提供了简单而强大的Node部署工具,包括:Heroku、Joyent、Cloud9等等。
Therefore, Node seem more powerful and with a lighter future, so if there isn't any constraint to use it (like existing code, servers, team capability), it is recommended for any new collaborative network project aiming high speed and scalability.
因此,Node 看起来更强大,更光明的未来,所以如果使用它没有任何限制(如现有代码、服务器、团队能力),建议用于任何以高速和可扩展性为目标的新协作网络项目。

