And that's why Python supports `asyncio` (not to be confused with `asyncore` which is obsolete). So I prefer:
sock = yield from connect('localhost', 7942)
msg = yield from read_message(sock)
print(msg)
to this callback hell: connect('localhost', 7942, function(sock) {
read_message(sock, function(msg)) {
console.log(msg);
});
});
And they're completely equivalent. Why would someone actually like the latter, except you're forced to use it because of the prevalence of JavaScript?`asyncio` is not only easier to use than the traditional "manual" state machines with classes, but also much faster than something like `Twisted`. In my crappy local benchmark[1], it easily beat `Twisted` in a considerable margin. That may be because of the flaws in my test code, but still their performance is on par. I see no points in relying on callback hell, at least in Python, except the lack of the libraries that support asyncio, which makes me a little bit sad.