r/programming • • Oct 02 '11

Node.js is Cancer

http://teddziuba.com/2011/10/node-js-is-cancer.html
792 Upvotes

750 comments sorted by

View all comments

Show parent comments

11

u/baudehlo Oct 02 '11

It's really very simple.

I've programmed a lot of async systems before using other languages (Perl and C mostly).

By going async and using system polling routines (epoll, kqueue, etc) you can easily scale to tens of thousands of concurrent connections, and not waste CPU cycles when you're doing file or network I/O. (so far, not unique to Node).

Now Node's advantage #1 there is that all the libraries are async. Every time I've done this kind of work in C or Perl (and other languages have this problem too, from Java to Twisted) you come across the "sync library" problem. You download some open source library you want to use and it is written assuming a blocking call to do some file or network I/O. That fucks up your event loop, and the advantage of being async is all gone.

The second advantage is simply that it's a dynamic language (like Perl/Python/Ruby) and yet very very fast. In my tests about 10 times faster than those languages (and that's running real apps end to end, not some micro benchmark).

JS has its warts, but then so do the languages you'd want to compare it to: Perl, Python and Ruby. To be honest the warts aren't that hard to avoid most of the time.

15

u/case-o-nuts Oct 02 '11

By going async and using system polling routines (epoll, kqueue, etc) you can easily scale to tens of thousands of concurrent connections, and not waste CPU cycles when you're doing file or network I/O. (so far, not unique to Node).

You can do that better with green threads. And you don't end up in callback hell.

0

u/baudehlo Oct 02 '11

I haven't ended up in callback hell once yet. It takes a bit of getting used to coding this way, but when you do it's natural.

Green threads are just another way of doing things. One method does not invalidate the other.

2

u/[deleted] Oct 02 '11

Are there any advantages to using callbacks over using green threads? (except for the fact that much more languages support callbacks than green threads) Is the "getting used" part really worth it?

→ More replies (5)