Live data from Hacker News

Node.js cures cancer

blog.brianbeck.com

81–90 of 99 posts

Re: Node.js cures cancer

#81

Earlier quoted context omitted.

i am not a node.js expert. one thing i am wondering is that, modern computers have more than just one core. how node.js utilizes these multiple cores?

By starting multiple processes. See cluster ( https://github.com/LearnBoost/cluster ), fugue ( https://github.com/pgte/fugue ), multi-node ( https://github.com/kriszyp/multi-node )

This is true for Python, Ruby, PHP. (I can't see ted's issues with node other than misunderstanding of the framework's runtime)

Re: Node.js cures cancer

#82
Node has a mantra which addresses this whole thread, right back to the beginning. "Everything in node runs in parallel, except your code". Manuel Kiessling has a written a great tutorial (http://nodebeginner.org) that shows how node noobs enter and can escape the blocking pitfall. Node is the right tool when your requests block on I/O. I'm not convinced about CPU heavy apps, yet.

Re: Node.js cures cancer

#83
post #33

IMHO i think node.js sucks because it forces you to manually pass callbacks around. can't it remember my call site for me and use coroutines or call/cc or yield or something? even fork() exists on UNIX (or pthread_create()). why is passing callbacks around the answer? it's like using GOTO.

It's painful but I can see why they don't want to be touching the V8 engine itself (as tempting as it probably is). Short of doing that you are stuck doing things the old-fashioned way (that is, callbacks).

I'm sure things will be a lot better if/when the V8 engine supports let/yield.

Re: Node.js cures cancer

#84
I read your benchmarks on Ruby, but you didn't list the implementation or version of Ruby you used.

I'd guess you used MRI 1.8.X.

I decided to benchmark other versions(and implementations) of Ruby.

= jruby 1.6.4 (7.3 seconds)

      user     system      total        real
  7.388000   0.000000   7.388000 (  7.349000)
= Rubinius 1.2.4 (Little under 6 seconds)

   user     system      total        real
  5.940015   0.006878   5.946893 (  5.842485)
= CRuby 1.9.2 (38 seconds)

      user     system      total        real
 38.250000   0.090000  38.340000 ( 38.376857)
= CRuby 1.8.7 (Little under 137 seconds)

      user     system      total        real
  136.960000   0.240000 137.200000 (137.437748)
Thanks!

Re: Node.js cures cancer

#85

It's the equivalent of tying a giant boulder to the back of a Ferrari 599 and scoffing at how Ferrari can dare to call it a "high performance" car. Stop trying to drag giant boulders around.

Not really. It's like saying "this ferrari doesn't need fuel!". Which is just bullshit.

Re: Node.js cures cancer

#86
post #41

I like how every rebuttal turns into "how fast can you compute a fibonacci number". I was looking for a function that burned a nontrivial amount of CPU, the choice of fibonacci was arbitrary. Let's move on from that. What I was showing was that if your request handler does a nontrivial amount of CPU work, it will hold up the event loop and kill any "scalability" you think you're getting from Node. If you Node guys we…

Node is an asynchronous programming framework bundled with a largely async library. If you have 40 cores on your system, you would presumably run 40 instances of node for a CPU intensive webserver(using multinode etc). So the event handler won't get stuck as long as there are available cores. What about a single core system? Well I guess a threaded/multi-process solution would time slice the fibonacci requests betwee…

If you use Python/Perl you will never really know the number of instances of the process to run

Eh? Think you could do async IO in both Perl & Python (and C and erlang ..) years before node came along..

Re: Node.js cures cancer

#87

Earlier quoted context omitted.

> Also, most other web stacks will discourage you from running a 30s fib on a thread processing web requests. This isn't specific to node. Difference being, with other stacks a request running for 30s will have little impact on the rest of the machine. With node, the whole server gets stuck, not just that precise request and the machine resources necessary to perform the computation (or whatever). The fib example is…

Only if you're crazy enough to put something in production running a single node instance.

I think this happens fairly often.

Re: Node.js cures cancer

#88
post #6

As a cancer survivor, just wanted to let you know that the poor taste exhibited here is pretty sad. When you want to make your point next time, use a title that doesn't include something that kills people. Thank you.

To be clear, the title is intended to point out how absurd the original title was (node.js is a cancer). I strongly suspect the author agrees with you on using this kind of language when describing a language/framework, which is exactly why he did include it in the title.

Re: Node.js cures cancer

#89
post #76
post #41

Earlier quoted context omitted.

Node is an asynchronous programming framework bundled with a largely async library. If you have 40 cores on your system, you would presumably run 40 instances of node for a CPU intensive webserver(using multinode etc). So the event handler won't get stuck as long as there are available cores. What about a single core system? Well I guess a threaded/multi-process solution would time slice the fibonacci requests betwee…

How is running 40 instances of node processes different from running 40 instances of a single threaded web server? How is running 40 instances of single threaded event loops better than running 10 instances of a process with 4 threads each? If you had a choice would you not rather have light-weight processes (threads) rather than actual processes because of lighter memory requirements? Threads are too hard to program…

> How is running 40 instances of node processes different from running 40 instances of a single threaded web server?

40 Instances of a single threaded webserver can block for I/O. If your webserver is 50% CPU bound this means that your CPU utilization is lower than in the case of a perfectly async system. You will serve fewer requests per second than an async framework. This is where the rule of thumb "no of threads = 2X no of cores" originates. Of course this rule wont work well for heavily I/O bound servers with high latency I/O. With node.js latency/IO percentage etc won't matter.

> If you had a choice would you not rather have light-weight processes (threads) rather than actual processes because of lighter memory requirements?

It would be great to have a multithreaded async framework. However a multithreaded environment eventually ends up introducing several blocking I/O functions which Dahl wanted to avoid. Hence the choice of Javascript.

node.js is one of a 100 possible solutions. Nobody insists that you use it. In fact I haven't even written a single line of node code. However I have done enough systems work to know the benefits of async programming.

> Threads are too hard to program to? Try STM?

STM can only handle scenarios that do not involve I/O. One of my colleagues was in the group at Microsoft tried STM with I/O that fell hard on their faces. Sure there are plenty of approaches - threads, actors, STM. Async programming is one such approach. If you want to write an async web server, right now node.js is the only solution. I think it might be possible to do a pure async web server in Haskell, as any IO gets captured in the type signature but I don't know of any async Haskell webserver framework.

> I'm not buying the notion that node's event model has any advantage over anything whatsoever.

You are basically asserting that async programming has no advantage over any other approach whatsoever. Having dug into hard disk device drivers, filesystems and caching for the Windows CE kernel, I would have killed to have a proper async I/O framework in CE from the ground up. We had a gazillion locks in the kernel modules, for gazillion data structures when all we really wanted to do was perform I/O without grabbing a lock. The Linux epoll, BSD kqueue and Windows IO completion ports are all async APIs added for high performance systems. These APIs are, strictly speaking, not required if you have threads but when you get into sufficiently advanced systems programming you cannot live without these. Trying to say that async programming is useless is equivalent to claiming that APIs such as epoll/kqueues are useless.

Re: Node.js cures cancer

#90
I think one thing that the article hints at is still relevant: "developers" nowadays throw around terms like "scalability" and other hype phrases and think that since they know the slightest thing about some new technology, they're a real developer. Sadly, this is incredibly naive. Any script kiddie / code monkey can some application in the latest over-hyped framework and say "HEY LOOK, IT CAN HAS NOSQL, IT CAN HAS SCALABILITY, IT DOES BIGGGGDATA", and write some inefficient code for this application. The truth is that many don't even understand basic data structures and how a computer processes information at a lower level. If you don't understand what something such as algorithmic complexity is, and can't look at your code from a more scientific and critical point of view, don't call yourself a freaking developer. Pick up a book and learn what REAL computer science is, not what the latest and greatest over-hyped framework is called.
Post reply on HN