IT:AD:Node.JS

Summary

Node.js brought about a revolution for JavaScript developers by allowing then to write code that runs directly on the machine; their skills were no longer limited to browsers alone.

At first, it was seen as a way to write application servers without needing to learn another language.

But it quickly became apparent that it could also be used to write tools invokable form the command line that automate a lot of things in our development cycles.

npm, bundled with Node.js, made this even easier, providing a means of easily obtaining tools that others have created, which we install on our machines to access from wherever we are in our system.

JavaScript was finally a “real” programming language.

What is it?

Node.JS is server-side evented I/O, using Chrome's V8 JavaScript engine.

  • Running on the server, using
  • Chrome's V8 JS engine, which is amazingly fast (you could say about 20% slower than C#, many times faster than Ruby: http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=v8&lang2=yarv
  • Evented IO:
    • Concurrent requests to a server can be handled by one of two ways:
      • Multiple threads (Apache, IIS, etc.)
      • Node uses a single non-blocking thread (Nginx, Thin, etc.) with an event loop.
        • Which is exactly what JS was originally designed for (in the browser).
        • It happens to be more efficient under high loads (see: http://nodejs.org/about/)
        • Combined with JS's efficient/easy passing around of closures, makes event-based programming simple (you call an I/O method, passing it an anon callback, and JS creates a closure, preserving state long after the calling method has gone out of scope.

Anybody using it?

Tools