1,135 karma · joined March 22, 2009
https://github.com/substack/dnode-protocol
It's written for continuation-passing style but it shouldn't be too hard to retrofit it for other call styles if you want to preserve explicit returns for instance.
This is pretty neat and I like the emphasis on getting stuff going in as few lines as possible but I'm not convinced that return values and implicit result callbacks are the way to go for asynchronous requests, which is how I understand this project to work. Often when you want to make a remote call you'll be doing some I/O on the server side, which in node is asynchronous so you can't return right away. Passing along a callback from the client side works much better when the I/O actions have some values to call the client back with.
(Edit: noticed that the article does it this way.)
How about just:
function insertCollection(collection, cb) {
if (collection.length === 0) cb(null);
else db.insert(collection[0], function (err) {
if (err) cb(err)
else insertCollection(collection.slice(1), cb)
}
}
That's hardly much more complex, and as a bonus won't lock up your whole program while db.insert() is working. You could use something like my own library Seq() too: var Seq = require('seq');
function insertCollection (collection, cb) {
Seq.ap(collection).seqEach(function () {
db.insert(c, this);
}).seq(cb).catch(cb)
}
That is, if you actually want the inserts to go sequentially. Usually you want them to go in parallel with say a maximum of 10 pending requests: var Seq = require('seq');
function insertCollection (collection, cb) {
Seq.ap(collection).parEach(10, function () {
db.insert(c, this);
}).seq(cb).catch(cb)
}
I don't see any "fundamental issue" with node here. It's just a very new ecosystem and the idioms and libraries are rapidly evolving.And there's a wikipedia entry for this even: http://en.wikipedia.org/wiki/Pushd_and_popd
conn.on('end', fn)
so that helps. At browserling.com all of our backend and frontend spanning lots of processes over several servers is tied together with dnode, and we haven't had any big problems tracking references that I can think of.Very curiously, these distributions are self-similar in that even when you restrict the sample to top-tier academics for instance, they still hold.
javascript:var theta = 0; setInterval(function () { theta += 0.05; parallax({ pageX : (Math.sin(theta) + 1) * 1000, pageY : (Math.cos(theta) + 1) * 1000}) }, 50)http://github.com/substack/rowbit
It's a pretty great fit since we already use IRC a ton to coordinate development so we see the notifications right away.
We often don't know ahead of time how a decision will work out, so calling these forks "wasted effort" seems to miss their utility as experiments that can drive the direction of future development indirectly.
var connect = require('connect');
var server = connect.createServer(connect.staticProvider(__dirname + '/static')).listen(4000);
Pow, that was easy! Plus, since connect (and express) are just up the prototype chain from http.Server, it works great with socket.io.My own RPC system enforces continuation passing style exclusively to unify the calling and return-value semantics. With this functional pattern in place it was pretty straight forward to transparently wrap arbitrarily many closures arbitrarily deeply in callback argument lists and method requests (which are the same thing under continuation passing style).
I was a bit confused when I hit the "quote-likes" section until I realized it was an aside however. A different colored box might be good for those.