ну марсоходы, точнее уже один марсоход насколько мне известно до сих пор под управлением Python, а всё, что не относится к колонизации космоса и науке - все эти ваши бложики, социальные сети, все это ваше
непотребство - не нужно и неинтересно.
/*
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)
А на самом деле, сейчас с подачи гугла с фейсбуком пришла мода на massively parallel web services, long polling и всякие веб-сокеты, и node.js позиционируется как решение именно для этой сферы.
Ну и в JIT в питоне ещё только-только на подходе, а в V8 он уже есть и работает, поэтому V8 шустрее и ест меньше памяти, а для корпораций означает, что они смогут запихать вдвое больше клиентов на свой сервак (а уж деньги считать они умеют).
И третья причина, JS мало-мальски знает любой вебобыдлокодер, поэтому node.js-быдлокодеры потенциально дешевле и не мнят себя илитой, в отличие от питонщиков.
мы на своем проекте как-то вначале попросили 3 машинки под питон сервера. Потом пооптимизировали... и в результате для достаточно нагруженного проекта у нас загрузка от силы процентов 10% от машинок