/* node.js vs Python with Greenlets (say gevent) I don't get why node.js is being so hyped. Sure, the idea of writing things in JavaScript both on the client and server-side is really nice. And JavaScript really fit an event-driven environment with its browser heritage. But why on earth is boomerang code so appealing to write? I don't get. Am I missing something obvious? All examples of node.js I see are littered with callbacks yet Ryan Dahl thinks coroutines suck. It doesn't add up for me. Would anyone mind explaining how node.js below is superior to the Python code at the bottom? Semi-pseudo node.js code with express.js follows: */ var memcached = ...; // From node-memcached var mongo = ...; // From mongoose app.get('/', function(req, res) { var a = null, b = null, c = null, d = null; memcached.get('mykey1', function(err, result) { if (err) { sys.puts('Naive error'); return; } a = result; memcached.get('mykey2', function(err, result) { if (err) { sys.puts('Naive error'); return; } b = result; mongo.find({name: 'Joe'}).each(function(doc) { // Errors handled by mongoose c = doc.age; mongo.find({name: 'Julia'}).each(function(doc) { d = doc.lastname; res.send('Hello World! ' + a + b + c + d); }); }); }); }); }); ######################################################################## # Compared to a Python semi-pseudo example based on Flask and gevent. @app.route("/") def hello(): a = memcached.get('mykey1') b = memcached.get('mykey2') c = mongo.find(name='Joe').first().age d = mongo.find(name='Julia').first().lastname return "Hello World! %s%s%s%s" % (a, b, c, d)