Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Node.js - Why JavaScript on the Server isn't as Bad an Idea as it Sounds

Justin Reidy
February 10, 2012

Node.js - Why JavaScript on the Server isn't as Bad an Idea as it Sounds

A quick introduction to Node.js, how it works, and how it's being used, aiming to dispel the FUD from the haters and the zealots.

Justin Reidy

February 10, 2012
Tweet

Transcript

  1. Node.js = Google V8 event reactor + core library +

    “a binding to V8 JavaScript for scripting network programs” - Ryan Dahl
  2. What’s V8? •Not a tomato drink •Google’s JavaScript engine •Compiles

    JS to machine code •The gift of the browser wars!
  3. Web Apps 101 •How to handle lots of web requests?

    •Prefork processes •Thread pool or spawning •Scaling FTW!
  4. Web Apps 101 •But... what about LOTS of concurrent requests?

    •Context switching threads can be slow •And what if each request needs file or network IO? •Serial processes can take too long to execute •Scaling... uh-oh
  5. Enter the Event Reactor! •One process per core, single thread

    per process •Start handling a request, pass it off, handle the next, go back to the first
  6. Node.js Event Reactor •Scale horizontally by spawning child processes •cluster.fork()

    allows message passing and TCP sharing •But what about shared state? HATEOAS
  7. Node.js core present low level interfaces and minimize abstractions “Node

    makes what was previously merely configurable into something more programmable, orthogonal, and more powerful.” - James Halliday (@substack)
  8. NPM •Dependencies installed locally •Conflicting sub-dependencies are ok! •Libraries are

    easy to debug and monkeypatch “Concurrent versioning and locality preference drastically accelerate the rate that we can iterate on new experiments and the levels of reuse that we can attain both in a single large project and among projects.” - @substack
  9. Worth the hype? •Yes and no. •The Typesafe stack is

    pretty awesome •Learn more about node! •Node docs - http://nodejs.org/ •“How to node” blog - http:// howtonode.org/ •Docs and guide: http://nodemanual.org •Node knockout app - https://github.com/ nko2/website/