SlideShare a Scribd company logo
Node.js
  How JavaScript is Changing Server Programming




Tom Hughes-Croucher                  @sh1mmer
This is how we roll

1. Server-Side JavaScript Overview
2. Introduction to Node.js
3. The Node.js ecosystem
4. Getting started
Server Side Javascript
  IS SO AWESOME
    MY ENTIRE PRESENTATION IS IN
          COMIC SANS
AND YOU WILL STILL LOVE ME AT THE END
Why SSJS?
JavaScript
programmers
    3>2>1
Massive Code base of YUI
 and other JS libraries
  I heard some people use this thing called jQuery,
         but I’m not convinced it’ll catch on
Laziness or “I’m sick
of writing stuff twice”
I could have said efficiency, but I think we all secretly long
              to lounge around in our y-fronts.
Progressive
Enhancement is free*
Remember WWCD (What Would Crockford Do)




                             *close enough
TL;DR:
SSJS is Awesome
 Like a Unicorn riding a Narwhal
Node.js and How JavaScript is Changing Server Programming
Why now?
1. Professionalism
Node.js and How JavaScript is Changing Server Programming
“Yahoo!'s corporate
 motto is: Don't be
      eval().“
“Doug Crockford's JavaScript is
    so strict, that uncaught
 exceptions would trigger global
      thermonuclear war“
2. JavaScript
   Runtimes
Runtimes

• V8 (Google), C++
• Spider Monkey (Mozilla), C++
• Rhino (Mozilla), Java
• JavaScript Core (Apple), C++
V8




                    Spider
                    Monkey

JavaScript Performance
Node.js
• Server-side JavaScript process
• Uses V8
• Non-blocking
• Event Driven
• CommonJS module format
AW Node.js
•
  ESServer-side JavaScript process



      OM
•   Uses V8

•   Non-blocking

•
•
    Event Driven
    CommonJS module format   E!
Node is
 ⎻⎻⎻⎻⎻
this fast
concurrency=300, Smaller is Better
                 400




                 300
response time (ms)




                                                                          server
                                                                             nginx
                 200                                                         thin
                                                                             tornado
                                                                             node_buffer


                 100




                       24      26    28    210     212      214   216   218
                                    response size (bytes)
Node.js and How JavaScript is Changing Server Programming
Why non-blocking
   matters
var result =
db.query("select * from T");
// use result
What are we waiting
       for?
Event Loop vs.
  Threads
Apache vs NGINX
concurrency × reqs/sec




http://blog.webfaction.com/a-little-holiday-present
Apache vs NGINX
concurrency × memory




http://blog.webfaction.com/a-little-holiday-present
Node Basics
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello Worldn');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');
var http = require('http');

//include the http library
http.createServer(function (req, res) {

}).listen(8124, "127.0.0.1");

//create an http server
//when ‘stuff’ happens call this anonymous function
//listen on port 8124 of the IP 127.0.0.1
http.createServer(function (req, res) {
   res.writeHead(200, {'Content-Type': 'text/plain'});
   res.end('Hello Worldn');
})

//when ‘stuff’ happens my function fires
//I get a request object and a response object
//I write to the response object header
//HTTP status 200 and content-type ‘text/plain’
//close the response with the body:
//Hello World
console.log('Server running at http://127.0.0.1:8124/');

//write Server is running at http://127.0.0.1:8124/
//to the console
Node Ecosystem
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming
Node.js and How JavaScript is Changing Server Programming
NPM
Node Package Manager
npm install mustache
NPM is written in
  JavaScript!
// kludge until this is normal.
if (!process.EventEmitter.prototype.on) {
  process.EventEmitter.prototype.on =
process.EventEmitter.prototype.addListener
}
var path = require("path")
if (!process.execPath) {
  process.execPath = path.join(process.installPrefix, "bin",
"node")
}

var npm = exports
  , set = require("./lib/utils/set")
  , get = require("./lib/utils/get")
  , ini = require("./lib/utils/ini")
  , log = require("./lib/utils/log")
  , fs = require("fs")

npm.commands = {}
npm.SHOULD_EXIT = true

try {
  var j = JSON.parse(fs.readFileSync(path.join(__dirname,
"package.json"))+"")
  npm.version = j.version
} catch (ex) {
  log(ex, "error reading version")
  npm.version = ex
}
node-repl
Interactive JavaScript terminal
Which libraries to
      use?
Mustache.js
Node.js and How JavaScript is Changing Server Programming
var view = {
  title: "Joe",
  calc: function() {
    return 2 + 4;
  }
}

var template = "{{title}} spends
{{calc}}";

var html = Mustache.to_html(template,
view);
node-paperboy
Node.js and How JavaScript is Changing Server Programming
http://
wargamez.mape.me/
Node.js and How JavaScript is Changing Server Programming
DOM+YUI3
Rendering HTML



http://yuiloader.davglass.com/calendar/
Multi-core Node.js
    Node+Web Workers
Master
 var sys = require('sys');
 var Worker = require('webworker').Worker;

 var w = new Worker('foo.js');

 w.onmessage = function(e) {
     sys.debug('Received mesage: ' + sys.inspect(e));
     w.terminate();
 };

 w.postMessage({ foo : 'bar' });



Worker
 onmessage = function(e) {
     postMessage({ test : 'this is a test' });
 };

 onclose = function() {
     sys.debug('Worker shuttting down.');
 };
Summary
•   SSJS is awesome because

    •   We are JavaScript programmers

    •   Reuse (libraries/code)

    •   Progressive Enhancement

•   Node.js + YUI3 rocks

    •   YUI 3’s was easy to get running on Node.js

    •   Server side DOM allows for a single code
        base
Today presentation was
 Brought to you by         And the fonts:
    the letters:            Comic Sans
      J and S                monofur

 Tom Hughes-Croucher       Slides, etc --> http://
      @sh1mmer           speakerrate.com/sh1mmer
croucher@yahoo-inc.com      Pls rate me. kthxbai.

More Related Content

KEY
node.js: Javascript's in your backend
KEY
Writing robust Node.js applications
PPTX
Introduction Node.js
KEY
OSCON 2011 - Node.js Tutorial
PPTX
NodeJS Concurrency
PPTX
introduction to node.js
PDF
Non-blocking I/O, Event loops and node.js
PPTX
Java script at backend nodejs
node.js: Javascript's in your backend
Writing robust Node.js applications
Introduction Node.js
OSCON 2011 - Node.js Tutorial
NodeJS Concurrency
introduction to node.js
Non-blocking I/O, Event loops and node.js
Java script at backend nodejs

What's hot (20)

KEY
NodeJS
PDF
NodeJS for Beginner
PDF
Server Side Event Driven Programming
PPTX
Introduction to node.js GDD
PDF
Getting started with developing Nodejs
PDF
Building servers with Node.js
PDF
NodeJS
PDF
Nodejs in Production
PPTX
Intro to Node.js (v1)
PPTX
Node.js Patterns for Discerning Developers
KEY
A million connections and beyond - Node.js at scale
PDF
Philly Tech Week Introduction to NodeJS
PDF
PDF
Node.js Explained
PDF
All aboard the NodeJS Express
PDF
Introduction to Node.js: What, why and how?
PPTX
Introduction to Node js
PDF
Nodejs presentation
PPT
Nodejs Event Driven Concurrency for Web Applications
PPT
Node js presentation
NodeJS
NodeJS for Beginner
Server Side Event Driven Programming
Introduction to node.js GDD
Getting started with developing Nodejs
Building servers with Node.js
NodeJS
Nodejs in Production
Intro to Node.js (v1)
Node.js Patterns for Discerning Developers
A million connections and beyond - Node.js at scale
Philly Tech Week Introduction to NodeJS
Node.js Explained
All aboard the NodeJS Express
Introduction to Node.js: What, why and how?
Introduction to Node js
Nodejs presentation
Nodejs Event Driven Concurrency for Web Applications
Node js presentation
Ad

Viewers also liked (17)

PPTX
Introduction to Node.js
PDF
JAX London 2015: Java vs Nodejs
PDF
Nginx, PHP, Apache and Spelix
PDF
Cucumber.js: Cuke up your JavaScript!
PPT
OpenWhisk Introduction
PPT
IBM Bluemix Openwhisk
PPTX
Domain driven design
PPTX
Node.js'e Hızlı Bir Bakış
PDF
Software Architecture for DevOps and Continuous Delivery
PDF
Java Application Servers Are Dead!
PDF
Spring4とSpring Bootで作る次世代Springアプリケーション #jjug #jsug
PPTX
WAS vs JBoss, WebLogic, Tomcat (year 2015)
PDF
Modern UI Development With Node.js
PPTX
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
PDF
Nodejs Explained with Examples
KEY
Node.js - Best practices
PDF
Node.js and The Internet of Things
Introduction to Node.js
JAX London 2015: Java vs Nodejs
Nginx, PHP, Apache and Spelix
Cucumber.js: Cuke up your JavaScript!
OpenWhisk Introduction
IBM Bluemix Openwhisk
Domain driven design
Node.js'e Hızlı Bir Bakış
Software Architecture for DevOps and Continuous Delivery
Java Application Servers Are Dead!
Spring4とSpring Bootで作る次世代Springアプリケーション #jjug #jsug
WAS vs JBoss, WebLogic, Tomcat (year 2015)
Modern UI Development With Node.js
WebSphere App Server vs JBoss vs WebLogic vs Tomcat (InterConnect 2016)
Nodejs Explained with Examples
Node.js - Best practices
Node.js and The Internet of Things
Ad

Similar to Node.js and How JavaScript is Changing Server Programming (20)

PDF
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
PDF
Developing realtime apps with Drupal and NodeJS
PPTX
ODP
Introduce about Nodejs - duyetdev.com
PPTX
Beginners Node.js
PPTX
PDF
Building web apps with node.js, socket.io, knockout.js and zombie.js - Codemo...
PPT
PDF
Node.js Presentation
PPTX
After the LAMP, it's time to get MEAN
PPTX
GeekCampSG - Nodejs , Websockets and Realtime Web
PDF
Node.js
PPT
18_Node.js.ppt
PDF
NodeJS ecosystem
PPTX
Node.js: A Guided Tour
PPT
18_Node.js.ppt
PPTX
Event-driven IO server-side JavaScript environment based on V8 Engine
PDF
Nodejs - A quick tour (v6)
PPTX
An overview of node.js
PDF
Node.js
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
Developing realtime apps with Drupal and NodeJS
Introduce about Nodejs - duyetdev.com
Beginners Node.js
Building web apps with node.js, socket.io, knockout.js and zombie.js - Codemo...
Node.js Presentation
After the LAMP, it's time to get MEAN
GeekCampSG - Nodejs , Websockets and Realtime Web
Node.js
18_Node.js.ppt
NodeJS ecosystem
Node.js: A Guided Tour
18_Node.js.ppt
Event-driven IO server-side JavaScript environment based on V8 Engine
Nodejs - A quick tour (v6)
An overview of node.js
Node.js

More from Tom Croucher (20)

PDF
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
KEY
Streams are Awesome - (Node.js) TimesOpen Sep 2012
KEY
Using Node.js to improve the performance of Mobile apps and Mobile web
KEY
Creating the Internet of Things with JavaScript - Fluent Conf
KEY
Using Node.js to make HTML5 work for everyone
PDF
Lessons from a coding veteran - Web Directions @Media
KEY
Multi-tiered Node Architectures - JSConf 2011
KEY
A language for the Internet: Why JavaScript and Node.js is right for Internet...
KEY
A language for the Internet: Why JavaScript and Node.js is right for Internet...
PDF
How to stop writing spaghetti code
PDF
Doing Horrible Things with DNS - Web Directions South
PDF
Doing Horrible Things to DNS in the Name of Science - SF Performance Meetup
KEY
How to stop writing spaghetti code - JSConf.eu 2010
PDF
Sf perf
PDF
Server Side JavaScript - You ain't seen nothing yet
PDF
JavaScript Everywhere! Creating a 100% JavaScript web stack
PDF
Mobile Data: How to avoid the latency trap - SWDC 2010
KEY
Let's run JavaScript Everywhere
KEY
Pirate yql
KEY
YQL Tutorial
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Streams are Awesome - (Node.js) TimesOpen Sep 2012
Using Node.js to improve the performance of Mobile apps and Mobile web
Creating the Internet of Things with JavaScript - Fluent Conf
Using Node.js to make HTML5 work for everyone
Lessons from a coding veteran - Web Directions @Media
Multi-tiered Node Architectures - JSConf 2011
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
How to stop writing spaghetti code
Doing Horrible Things with DNS - Web Directions South
Doing Horrible Things to DNS in the Name of Science - SF Performance Meetup
How to stop writing spaghetti code - JSConf.eu 2010
Sf perf
Server Side JavaScript - You ain't seen nothing yet
JavaScript Everywhere! Creating a 100% JavaScript web stack
Mobile Data: How to avoid the latency trap - SWDC 2010
Let's run JavaScript Everywhere
Pirate yql
YQL Tutorial

Recently uploaded (20)

PDF
Modernizing your data center with Dell and AMD
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Big Data Technologies - Introduction.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
KodekX | Application Modernization Development
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Modernizing your data center with Dell and AMD
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Building Integrated photovoltaic BIPV_UPV.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Electronic commerce courselecture one. Pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Dropbox Q2 2025 Financial Results & Investor Presentation
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Big Data Technologies - Introduction.pptx
MYSQL Presentation for SQL database connectivity
Unlocking AI with Model Context Protocol (MCP)
KodekX | Application Modernization Development
The AUB Centre for AI in Media Proposal.docx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
NewMind AI Weekly Chronicles - August'25 Week I
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Machine learning based COVID-19 study performance prediction
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy

Node.js and How JavaScript is Changing Server Programming