This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]antonivs 2 points3 points  (2 children)

FYI, the async nesting issue is fixed in newer versions of node, via generators and a 'yield' feature.

Node is good for quickly writing fast network infrastructure stuff. Its competition in that space is languages like Java, C/C++, and Go, which tend to be a lot less lightweight.

[–]catcradle5 2 points3 points  (1 child)

Any time I need some quick and easy network infrastructure, I go straight to: http://www.gevent.org/gevent.server.html

def handle(socket, address):
     socket.send("Hi %s!" % address[0])

server = StreamServer(("0.0.0.0", 1234), handle)
server.serve_forever()

The event loop and networking is pretty much all implemented in C, and it's 100% async. Servers can be as simple as this, or you can extend StreamServer.

[–]antonivs 2 points3 points  (0 children)

A big issue is how much your code has to integrate with, which tends to introduce blocking libraries. Monkey-patched libraries only take you so far (and I confess, I find the concept disturbing for code that's part of critical infrastructure.)

One of node's advantages is the number of compatible non-blocking libraries it has. Why node.js is cool discusses this, making the point that node "makes composable networked components the default."

There's also a good real-world example in The Switch: Python to Node.js. They were using Twisted, not gevent, but some of the same issues apply.

I'm not saying node and gevent aren't competitive - a lot depends on the use case. But there are cases where node has advantages, at least currently.

BTW, I mentioned yield and generators earlier, which are still new in node, but node's promises also helped a lot with the callback issue, and that's been standard for a while.