http://blogs.msdn.com/b/dsyme/archive/2010/02/15/async-and-p...
Is NodeJS Wrong?
11–20 of 47 posts
Re: Is NodeJS Wrong?
#12This is a bit annoying since if you want to make three async requests you have to write the following Well, beyond a style issue. You can unfold the events and make it a lot less "annoying". Consider, var cb1 = function() { } var cb2 = function() { req(cb1); } var cb3 = function() { req(cb2); } req(cb3); It's a lot cleaner and it looks like a state machine (and kind of looks like erlang/message passing).
var not_formatted;
var formatted;Re: Is NodeJS Wrong?
#13Re: Is NodeJS Wrong?
#14Several commenters point out that long-running computations can be performed outside the main request thread without the server having to do anything special. It's also possible to divide up long-running computations oneself. This can lead to very interesting designs.
Re: Is NodeJS Wrong?
#15Given any long-running task, there are two natural things to do: 1. Do something while the long-running task is running 2. Do something after the long-running task has completed Node.js' callback function convention simply makes it stupendously easy for you to write code for both cases, and leans towards making case (1) as natural as possible. Case (2) is naturally easy in Javascript (and even easier in Coffeescript)…
To me, it seems the real weakness of node.js is having to manage asynchronous control flow yourself, at all . It grows exponentially more ugly as the system increases in size. I really like continuation-passing-style as a technique (especially as a compiler IR), but doing that stuff by hand is so 70s . I got pretty far along writing a similar system in Lua (because, hey, event-driven systems are pretty nice), and unl…
I'm looking for a language that can do everything that Node.js does but also solves this control flow problem, but is also fast and has support for OpenCL and beefy math libraries.
I don't find Erlang to be performant in this regard, so I'm looking at Scala but I'm constantly getting pissed.at.java.packages.and.conventions. I think it also suffers from the same problems as Node.js and doesn't support the async/control-flow magic that Haskell supposedly has.
Perhaps I should consider Haskell after all. It's that or C++.
Re: Is NodeJS Wrong?
#16This is a bit annoying since if you want to make three async requests you have to write the following Well, beyond a style issue. You can unfold the events and make it a lot less "annoying". Consider, var cb1 = function() { } var cb2 = function() { req(cb1); } var cb3 = function() { req(cb2); } req(cb3); It's a lot cleaner and it looks like a state machine (and kind of looks like erlang/message passing).
Re: Is NodeJS Wrong?
#17Earlier quoted context omitted.
To me, it seems the real weakness of node.js is having to manage asynchronous control flow yourself, at all . It grows exponentially more ugly as the system increases in size. I really like continuation-passing-style as a technique (especially as a compiler IR), but doing that stuff by hand is so 70s . I got pretty far along writing a similar system in Lua (because, hey, event-driven systems are pretty nice), and unl…
Thanks for this, you've nailed the problem. I'm looking for a language that can do everything that Node.js does but also solves this control flow problem, but is also fast and has support for OpenCL and beefy math libraries. I don't find Erlang to be performant in this regard, so I'm looking at Scala but I'm constantly getting pissed.at.java.packages.and.conventions. I think it also suffers from the same problems as…
Re: Is NodeJS Wrong?
#18Several commenters point out that long-running computations can be performed outside the main request thread without the server having to do anything special. It's also possible to divide up long-running computations oneself. This can lead to very interesting designs.
Then why am I using Node.js? Any language has been able to do that for over a decade now, without the other hoops Node.js's style forces you to jump through. As evil and bad as shared-state multithreading truly is, this is a (or possibly "the") task it can manage without blowing up.
This is all but an admission that Node.js actually has no concurrency story at all. Hardly surprising, since it doesn't, unless "We force the programmer to do all the concurrency work" counts.
"This can lead to very interesting designs."
Yes, in the "may you live in interesting times" sense of interesting, absolutely. If you're going to reduce yourself to manually scheduling everything yourself why boot an OS at all? (Yes, that's a bit of an exaggeration, but seriously, think about it for a bit, there's truth there. Runtimes/VMs/languages ought to be adding to the OS, not fundamentally subtracting from it.)
Re: Is NodeJS Wrong?
#19Re: Is NodeJS Wrong?
#20It looks like the compute situation in Node.js can be helped with a server side web workers implementation .. with the workers doing no IO and only computes. Any thoughts?