

Why Node.js Is Totally Awesome - chetan51
http://chetansurpur.com/blog/2010/10/why-node-js-is-totally-awesome.html

======
jimmyjazz14
This reads a bit like a parody of all the other node is awesome blog post out
there. Node is fine and all but maybe it's time to put down the kool-aid. Also
I find it a little bold to claim that node is "faster than any other server
language / platform out there", even worse there is absolutely no numbers to
back up any of this guys claims.

------
zbanks
I _cringe_ whenever people bring up point 1.

Just because your front-end uses JS, doesn't mean that the same code runs on
the back-end. You still have to write new code.

I guess there _are_ 2 good parts about it, though. For one, you get awesome
HTML/XML parsing & traversing out of the box. Which can be nice, I guess.

Also, you get to use some preexisting JS libraries. Underscore is the biggest
one that comes to mind. (Does coffeescript work? haven't tried that one)
JQuery works theoretically, but it does mostly DOM stuff, which isn't used
enough to warrant the huge lib.

~~~
jashkenas
Yes, CoffeeScript produces plain-vanilla JavaScript that works fine on both
the browser and the server. The CoffeeScript compiler itself also works in any
JS runtime...

For an example of what a CoffeeScript/Node app looks like, take a peek at
this:

[http://github.com/jashkenas/api-
playground/blob/master/src/a...](http://github.com/jashkenas/api-
playground/blob/master/src/app.coffee)

~~~
zbanks
Thanks. I assumed it would. Cool link.

------
mcantor
Is it possible to gain a thorough appreciation for the benefits and technical
implementation of a project like Node.js without being knee-deep in the
scalable web app universe? Nothing I have written has needed to handle more
than, oh, six requests per eon yet, so I have never felt the constraints of
"synchronous, I/O-bound" software development.

I put "synchronous, I/O-bound" in scare quotes because I don't really _grok_
what it means. Sure, I can talk the talk and mumble a few buzzwords under my
breath, but when it really comes down to it, I have only a cursory
understanding of what "event driven," "asynchronous" or, Hell, even " _single
threaded_ " means. I've read the Wikipedia pages and made it to "Hello world"
with a few of these concepts, but I feel like I'm really missing a huge chunk
of very important knowledge & experience.

What kind of project can I work on that would go down this road? Are there any
good books, physical or electronic? Or am I doomed to be disconnected from
this universe of experience until one of my crappy web projects gets Digged
and I learn through trial by fire? I just know there's more to this than
"asynchronous method calls will not block method calls that come after them."

EDIT: I noticed that someone downvoted this--I'd be extremely interested to
know why. Am I missing something incredibly obvious?

~~~
aarongough
Try making something that depends on an I/O resource that is _really_ slow,
that will give you more of a feeling for it quickly.

I did this in one of my projects (Ajax-Gist.com) where I was directly querying
a 3rd party API (GitHub) for each request. That meant that each request was
client->server roundtrip time plus server->api roundtrip time, which worked
out to be around 200ms, or a total throughput of 5 requests per second.

This is obviously unacceptable and a complete waste of resources so I re-wrote
the whole thing to be asynchronous. The new application, running in a single
thread on the same hardware can now handle around 70 requests per second with
30 concurrent users. That's pretty damn fast for a Rails application...

Now I didn't use Node to solve my problem (though I considered it!) but the
principles and the message I took away was the same. I think it's a handy tool
to have in your toolkit, but as you've already realized it's simply not
necessary for a lot of projects, particularly smaller ones.

~~~
mcantor
Just FYI, <http://ajaxgist.com> results in a 404.

What library/technique did you end up using to make your app asynchronous?

~~~
aarongough
Haha, I got my own domain name wrong! Clearly it's been a long day...

Link: <http://ajax-gist.com/>

In the end I built what was essentially a proof-of-concept asynchronous Rails
3 application. The libraries I used under the hood to get everything async
were:

* Rack/Fiber-Pool: <http://github.com/mperham/rack-fiber_pool>

* EM Synchrony: <http://github.com/igrigorik/em-synchrony>

* Eventmachine: <http://rubyeventmachine.com/>

Using Rails for what is essentially a thin proxy is overkill, and I could have
gotten better performance with Node or by writing a Rack application directly.
But I wanted to take the opportunity to get a handle on what would be involved
with doing this in Rails, as not too many people have done it before that I am
aware of (and at the time no-one had done it with Rails 3).

~~~
mcantor
Thanks! It sounds like you definitely blazed a couple of trails. Nicely done!
I shall certainly peruse all of this; I appreciate the thorough response.

~~~
aarongough
No worries! I'm always happy to answer questions via email as well if need be.

------
mcantor
I can't believe I'm turning into "that guy who bellyaches about profanity,"
but... did the "beep beep, _motherfucker_ " really add anything to the post?

~~~
jimmyjazz14
I generally hate casual swearing only for the fact that it degrades the shock
value all of our best swear words.

~~~
mcantor
You're right. It's a fucking tragedy, is what it is.

------
jcromartie
I am pretty interested in the potential for multiplayer game servers written
in Node.js. Most every post about Node that I have seen seems to focus on it
as a web server/web app platform... but it's not. Using JavaScript for the
game on the client side (and I don't mean in a browser) would make it that
much better.

~~~
jashkenas
Here are links to two in-progress fun ones (use Chrome for these), as well as
some bits of their source code that are worth reading through...

Lazeroids:

<http://www.lazeroids.com>

[http://github.com/gerad/lazeroids-
node/blob/master/lazeroids...](http://github.com/gerad/lazeroids-
node/blob/master/lazeroids.coffee)

Orona:

<http://stephank.github.com/orona/bolo.html>

[http://github.com/stephank/orona/blob/master/src/objects/tan...](http://github.com/stephank/orona/blob/master/src/objects/tank.coffee)

... those are in-browser, of course, but a lot of that logic isn't browser-
specific.

------
equark
What's the Javascript story on the server side when we have real
interoperability needs? For instance, in the corporate world where there are
huge Java or .NET libraries that I absolutely need to access with good
performance.

Is there an easy path to access JVM and .NET code with V8? And if not, has
Microsoft released an interoperability story for the ie9 javascript engine?

Clearly there is huge momentum with javascript as a dynamic scripting
language, which probably is going to last a while given that the client side
is going to stay javascript for a while. But I'm wondering if it can replace
Jython/IronPython where those are needed.

------
ericflo
Is this article serious, or is it a parody? (Honest question)

------
ph0rque
So how does the concurrency of node.js compare to a web framework written in
Erlang?

------
ergo98
ASP pages could be written in Microsoft's ECMAScript variation of JavaScript
(JScript), and they even carried the tradition on to JScript.NET (with blazing
fast performance. JScript.NET was the underappreciated step-child of the .NET
ecosystem).

<http://msdn.microsoft.com/en-us/library/ms974588.aspx>

I don't even know if that is still around, as it never really gained much
traction.

Nonetheless, I was using the "same language on the client and the server"
argument 14 years ago. Nice to see the world caught up to my utter brilliance.

------
darkhorse
he left out this caveat about the nginx comparison:

"Please take with a grain of salt. Very special circumstances. NGINX peaked at
4mb of memory Node peaked at 60mb."

