English 中文(简体)
Other language (frameworks) where the event loop is exposed as a language construct?
原标题:

At http://nodejs.org/#about it says the following:

"Node is similar in design to and influenced by systems like Ruby s Event Machine or Python s Twisted. Node takes the event model a bit further—it presents the event loop as a language construct instead of as a library."

Are there other frameworks or languages that likewise expose the event loop?

最佳回答

Tcl has had this capability all along (last 2 decades). See http://www.tcl.tk/about/netserver.html

This is not to say Tcl does -- or should do -- everything Javascript and/or node.js does. But it is a valid answer to the question as to what "other frameworks or languages ... likewise expose the event loop?"

问题回答

To be honest, I don t think there is something that s comparable to Node.js at the moment.

Why? Well basically because of the fact that JavaScript was single threaded from the start off, this made the language evolve in what it is today, a language that s perfectly fit for asynchronous programming, like you do it in Node.js.

Functions being first class objects, as well as having closures is a must if you want a Node like experience. For example you could just as well wrap plain C around the event lib and use that. But how much fun would that be? Even with twisted, you don t get even near the Node.js experience.

Second point is that Node.js has - except for the sync functions of the fs modules - no blocking functions, so while you can certainly do this style of programming in Python, you never know for sure if that library call isn t going to block your whole program. And kill the throughput of your server.

Also Node is fast, like in REALLY fast. V8 is definitely way ahead of Python and Ruby, yes you can write C-Extensions for both, but you can just as well do that for Node.js. Another plus point of using V8, Google is investing a ton of time/money into that Engine, another up to 2x improvement is already on the way with Crankshaft.

Node.js has more plus points, it s a complete framework (while Twisted is mainly async networking) and it s JavaScript.

The latter one may sound stupid, but the ability to re-use code and not having to do context switching , as well as being able to use mature frameworks for DOM manipulation (well, that is as soon as jsom gets into a more stable state) is another killer feature.

If you haven t done yet, I recommend you watch a couple of the talks listed on our Tag Wiki.
Especially the YUI one shows what possibilities await us in the near future.

So to sum it all up:
Although there are quite some frameworks out there that have an event loop, just having the loop itself won t give you the same experience as Node.js, so you should not expect a comparable experience when doing stuff in C or Java for example.

For the java platform I guess you could compare netty to node.js





相关问题
What is an event loop or run loop?

In iPhone development, I have come across these terms named event loop, run loop . Can some one explain explain what they are?

GLib——C++的主要活动范围

我需要在C++实施我自己的主要活动,该活动将建立在GLib图书馆的基础上。 我不知道何时开始。 我研究了一些关于GLib的材料,但我不知道如何执行。

Asynchronous event loop design and issues

I m designing event loop for asynchronous socket IO using epoll/devpoll/kqueue/poll/select (including windows-select). I have two options of performing, IO operation: Non-blocking mode, poll on ...

socket server framework like Tcl "socket -server"

I m looking to reimplement some Tcl code that uses the socket -server construct [1]. What s the best option in Python for a small, industrial strength multi-user network-based server that includes ...

热门标签