The main advantage of node.js is that all its libraries are async so you don't have to worry much about blocking. There are async libraries for mysql, postgres, redis, etc. All is async by default.
Python have a library for anything - but most of these libraries are not asynchronous. In order to take advantage of tornado (and not to block the process) special libraries for are necessary (e.g. you can't just 'pip install redis' and use it, you'll need something like brukva), and there are much less tornado libraries than node.js libraries. There is no async mysql tornado driver available at the moment, for example (or at least I'm not aware of it).
But you can still use many python libraries with tornado (ones that doesn't do i/o), and tornado community is raising and filling the gaps.
It is easier to write an app using node.js than using tornado in my experience. I personally switched to tornado from node.js because it fits into existing infrastructure of my python project better (integration between django site serving html pages and tornado server providing realtime features was quite painless).
V8 应该使 JS 比 Python 更快 至少基准看起来是这样建议,但这可能并不重要,因为 Node.js 和 Tornado (以及大多数其他 Web 框架)都使用本机库的包装器。许多 Python 标准库都是用 C 编写的,或者可以用更快的替代方案替换,从而进一步减少潜在的差异。
Web 服务通常受 I/O 限制,因此这意味着我们要花时间等待数据存储而不是处理数据。这使得 JS 和 Python 之间的合成速度差异在许多应用程序中变得无关紧要。
As Rich Bradshaw points out Node.js is written in JS, which means you can keep the front end and the back end in the same language and possibly share some codebase. To me that is a huge potential benefit of Node.js. Node also comes with more asynchronous libraries out of the box it seems.
V8 should make JS faster than Python at least that's what benchmarks seem to suggest, but it may not matter much, because both Node.js and Tornado (and most other web frameworks for that matter) use wrappers for native libraries. A lot of the Python standard library is written in C or can be replaced by a faster alternative, which mitigates potential differences even more.
Web services are usually I/O bound, so that means we're spending the time waiting for the data store and not processing the data. That makes the synthetic speed difference between JS and Python irrelevant in many applications.
node.js uses V8 which compiles into assembly code, tornado doesn't do that yet.
Other than that (which doesn't actually seem to make much difference to the speed), it's the ecosystem. Do you prefer the event model of JS, or the way Python works? Are you happier using Python or JS libraries?
Nodejs also has a seamless integration / implementation of websockets called Socket.io. It handles browsers supporting sockets - events and also has backward polling compatibility for older browsers. It is quite quick on development requiring a notification framework or some similar event based programming.
I would suggested you go with NodeJS, if there is no personal pref to python. I like Python a lot, but for async I choose Tornado over node, and later had to struggle finding way to do a thing, or libraries with async support (like Cassandra has async in tests, but nowhere could I find way to use cqlengine with async. Had to choose Mongo since I already surpassed the deadline). In terms of performance and async, Node far better than tornado.
发布评论
评论(5)
Node.js 的主要优点是它的所有库都是异步的,因此您不必太担心阻塞。 mysql、postgres、redis 等都有异步库。默认情况下都是异步的。
Python 有一个适用于任何事物的库 - 但大多数这些库都不是异步的。为了利用龙卷风(而不是阻止进程),需要特殊的库(例如,您不能只是“pip install redis”并使用它,您需要类似 brukva),并且tornado库比node.js库少得多。例如,目前没有可用的异步 mysql 龙卷风驱动程序(或者至少我不知道)。
但是你仍然可以在tornado中使用许多python库(那些不执行i/o的库),并且tornado社区正在提出并填补空白。
根据我的经验,使用node.js 编写应用程序比使用tornado 更容易。我个人从node.js切换到tornado,因为它更适合我的python项目的现有基础设施(提供html页面的django站点和提供实时功能的tornado服务器之间的集成非常轻松)。
The main advantage of node.js is that all its libraries are async so you don't have to worry much about blocking. There are async libraries for mysql, postgres, redis, etc. All is async by default.
Python have a library for anything - but most of these libraries are not asynchronous. In order to take advantage of tornado (and not to block the process) special libraries for are necessary (e.g. you can't just 'pip install redis' and use it, you'll need something like brukva), and there are much less tornado libraries than node.js libraries. There is no async mysql tornado driver available at the moment, for example (or at least I'm not aware of it).
But you can still use many python libraries with tornado (ones that doesn't do i/o), and tornado community is raising and filling the gaps.
It is easier to write an app using node.js than using tornado in my experience. I personally switched to tornado from node.js because it fits into existing infrastructure of my python project better (integration between django site serving html pages and tornado server providing realtime features was quite painless).
正如 Rich Bradshaw 指出的那样,Node.js 是用 JS 编写的,这意味着您可以使前端和后端使用相同的语言,并且可能共享一些代码库。对我来说,这是 Node.js 的巨大潜在优势。
Node 似乎还附带了更多开箱即用的异步库。
V8 应该使 JS 比 Python 更快 至少基准看起来是这样建议,但这可能并不重要,因为 Node.js 和 Tornado (以及大多数其他 Web 框架)都使用本机库的包装器。许多 Python 标准库都是用 C 编写的,或者可以用更快的替代方案替换,从而进一步减少潜在的差异。
Web 服务通常受 I/O 限制,因此这意味着我们要花时间等待数据存储而不是处理数据。这使得 JS 和 Python 之间的合成速度差异在许多应用程序中变得无关紧要。
As Rich Bradshaw points out Node.js is written in JS, which means you can keep the front end and the back end in the same language and possibly share some codebase. To me that is a huge potential benefit of Node.js.
Node also comes with more asynchronous libraries out of the box it seems.
V8 should make JS faster than Python at least that's what benchmarks seem to suggest, but it may not matter much, because both Node.js and Tornado (and most other web frameworks for that matter) use wrappers for native libraries. A lot of the Python standard library is written in C or can be replaced by a faster alternative, which mitigates potential differences even more.
Web services are usually I/O bound, so that means we're spending the time waiting for the data store and not processing the data. That makes the synthetic speed difference between JS and Python irrelevant in many applications.
Node.js 使用 V8 编译成汇编代码,但 Tornado 还没有这样做。
除此之外(实际上似乎对速度没有太大影响),就是生态系统。你更喜欢 JS 的事件模型,还是 Python 的工作方式?您更喜欢使用 Python 还是 JS 库?
node.js uses V8 which compiles into assembly code, tornado doesn't do that yet.
Other than that (which doesn't actually seem to make much difference to the speed), it's the ecosystem. Do you prefer the event model of JS, or the way Python works? Are you happier using Python or JS libraries?
Nodejs 还具有名为 Socket.io 的 Websockets 无缝集成/实现。它处理支持套接字事件的浏览器,并且还具有对旧浏览器的向后轮询兼容性。它的开发速度非常快,需要通知框架或一些类似的基于事件的编程。
Nodejs also has a seamless integration / implementation of websockets called Socket.io. It handles browsers supporting sockets - events and also has backward polling compatibility for older browsers. It is quite quick on development requiring a notification framework or some similar event based programming.
如果没有个人对 python 的偏好,我建议你使用 NodeJS。我非常喜欢Python,但对于异步,我选择Tornado而不是node,后来不得不努力寻找做某事的方法,或者具有异步支持的库(例如Cassandra在测试中具有异步,但我无处可以找到将cqlengine与async. 不得不选择 Mongo,因为我已经超过了截止日期)。
在性能和异步方面,Node远远优于tornado。
I would suggested you go with NodeJS, if there is no personal pref to python. I like Python a lot, but for async I choose Tornado over node, and later had to struggle finding way to do a thing, or libraries with async support (like Cassandra has async in tests, but nowhere could I find way to use cqlengine with async. Had to choose Mongo since I already surpassed the deadline).
In terms of performance and async, Node far better than tornado.