SlideShare a Scribd company logo

Dcjq node.js presentation

A
async_io

Node.js: What Is It, How Does It Work, and What Can I Use It For Tomorrow?

1 of 54
dcjq[5] Node.js: What Is It, How
 Does It Work, and What Can I
     Use It For Tomorrow?


             April 28, 2011
            Jonathan Altman
             http://async.io/
               @async_io
what we’ll cover
• What node is
• Why node is the way it is
• What you can do with it
• Set up a running framework to build web apps
• Dissect a simple node web application
node.js is:
•   A non-browser Javascript toolkit/
    framework started by Ryan Dahl
•   Available for *nix-based systems: Linux, OS X, OpenSolaris (and Windows)

•   Built on top of Google’s V8 Javascript engine

•   Compatible with many common Javascript libraries out of the box via
    CommonJS support (http://www.commonjs.org/)

•   A batteries-included framework: HTTP and socket support baked into the
    core of the framework

•   A framework that is easy to build tooling on top of

•   Most importantly: asynchronous from the ground up
node.js is:
•   A non-browser Javascript toolkit/framework started by Ryan Dahl


•   Available for *nix-based systems: Linux,
    OS X, OpenSolaris (and Windows)
•   Built on top of Google’s V8 Javascript engine

•   Compatible with many common Javascript libraries out of the box via
    CommonJS support (http://www.commonjs.org/)

•   A batteries-included framework: HTTP and socket support baked into the core
    of the framework

•   A framework that is easy to build tooling on top of

•   Most importantly: asynchronous from the ground up
node.js is:
•   A non-browser Javascript toolkit/framework started by Ryan Dahl

•   Available for *nix-based systems: Linux, OS X, OpenSolaris (and Windows)


•   Built on top of Google’s V8 Javascript
    engine
•   Compatible with many common Javascript libraries out of the box via
    CommonJS support (http://www.commonjs.org/)

•   A batteries-included framework: HTTP and socket support baked into the
    core of the framework

•   A framework that is easy to build tooling on top of

•   Most importantly: asynchronous from the ground up
node.js is:
•   A non-browser Javascript toolkit/framework started by Ryan Dahl

•   Available for *nix-based systems: Linux, OS X, OpenSolaris (and Windows)

•   Built on top of Google’s V8 Javascript engine


•   Compatible with many common Javascript
    libraries out of the box via CommonJS
    support (http://www.commonjs.org/)
•   A batteries-included framework: HTTP and socket support baked into the core of
    the framework

•   A framework that is easy to build tooling on top of

•   Most importantly: asynchronous from the ground up
node.js is:
•   A non-browser Javascript toolkit/framework started by Ryan Dahl

•   Available for *nix-based systems: Linux, OS X, OpenSolaris (and Windows)

•   Built on top of Google’s V8 Javascript engine

•   Compatible with many common Javascript libraries out of the box via CommonJS
    support (http://www.commonjs.org/)


•   A batteries-included framework: HTTP
    and socket support baked into the core
    of the framework
•   A framework that is easy to build tooling on top of

•   Most importantly: asynchronous from the ground up
node.js is:
•   A non-browser Javascript toolkit/framework started by Ryan Dahl

•   Available for *nix-based systems: Linux, OS X, OpenSolaris (and Windows)

•   Built on top of Google’s V8 Javascript engine

•   Compatible with many common Javascript libraries out of the box via
    CommonJS support (http://www.commonjs.org/)

•   A batteries-included framework: HTTP and socket support baked into the
    core of the framework


•   A framework that is easy to build
    tooling on top of
•   Most importantly: asynchronous from the ground up
node.js is:
•   A non-browser Javascript toolkit/framework started by Ryan Dahl

•   Available for *nix-based systems: Linux, OS X, OpenSolaris (and Windows)

•   Built on top of Google’s V8 Javascript engine

•   Compatible with many common Javascript libraries out of the box via
    CommonJS support (http://www.commonjs.org/)

•   A batteries-included framework: HTTP and socket support baked into the
    core of the framework

• A framework that is easy to build tooling on top of
• Most importantly: asynchronous
    from the ground up
so what does code look like?
node.js script to determine if
         a file exists


          Running it yields:
whoa, back up: asynchronous?
•   Core trait of the framework
•   Provides scalability
• Long-running operations do not block your server
• Coding looks odd for server writers
whoa, back up: asynchronous?
• Core trait of the framework
• Provides scalability
• Long-running operations do not block your server
• Coding looks odd for server writers
whoa, back up: asynchronous?
• Core trait of the framework
• Provides scalability
• Long-running operations do not block
  your server
• Coding looks odd for server writers
whoa, back up: asynchronous?
• Core trait of the framework
• Provides scalability
• Long-running operations do not block your server
• Coding looks odd for server writers
code looks odd?
• node:                                                      • jQuery:
var sys = require('sys'),                                           $('.station_map').live("pagecreate", function() {

 path = require('path'),                                        if(navigator.geolocation) {

 fs = require('fs');                                              navigator.geolocation.getCurrentPosition(function(position){
                                                                     initializeMap(position.coords.latitude,position.coords.longit
var fileName = process.ARGV[2];                               ude);
path.exists(fileName, function(exists) {                            });

 if (!exists) {                                                 }

 
 sys.puts(fileName + ' not found');                          });

 
 return;                                                  // snippet taken from https://github.com/mikeymckay/Capital-

 }                                                          Bikeshare/blob/master/capitalbikeshare.js


 sys.puts('w00t! ' + fileName + ' exists!');
});
// https://github.com/jonathana/dcjq_5_nodejs/blob/master/
node_async_example.js




 Doesn’t the code look just like the event-driven javascript DHTML-
           based web apps have been written in for years?
node: up and running
•   node.js and its ecosystem still
    evolves very fast
•   Highly recommended to not put any of it in your
    system paths
•   We’ll use ~/local (lots of examples do so...)
node: up and running
• node.js and its ecosystem still evolves very fast
•   Highly recommended to not put
    any of it in your system paths
• We’ll use ~/local (lots of examples do so...)
node: up and running
•   node.js and its ecosystem still evolves very fast
• Highly recommended to not put any of it in your
    system paths

•   We’ll use ~/local (lots of
    examples do so...)
be careful for:
•   Highly recommended not to
    install node in “system”
    locations yet
•   Uncertain security/threat model
• Hide behind a reverse proxy
be careful for:
• Highly recommended not to install node in
    “system” locations yet

•   Uncertain security/threat model
• Hide behind a reverse proxy
be careful for:
• Highly recommended not to install node in
    “system” locations yet
•   Uncertain security/threat model

•   Hide behind a reverse proxy
be careful for:
• Highly recommended not to install node in
    “system” locations yet
•   Uncertain security/threat model
• Hide behind a reverse proxy
•   Everything in this presentation
    could be wrong by now!
basic components
•   node.js itself
• nave: manages multiple versions of node
• npm: node package manager. Like ruby’s gem or
    python’s easy_install
basic components
•   node.js itself

•   nave: manages multiple versions
    of node
•   npm: node package manager. Like ruby’s gem or
    python’s easy_install
basic components
•   node.js itself
• nave: manages multiple versions of node
•   npm: node package manager.
    Like ruby’s gem or python’s
    easy_install
managing versions-nave
•   Again, node.js and its libraries
    move fast
• Like python’s virtualenv or ruby’s rvm, there are
    nave and nvm for node
•   Let’s use nave
• Allows us to have a “stable” environment
• Allows us to test newer versions without risking
    “stable”
managing versions-nave
•   Again, node.js and its libraries move fast

•   Like python’s virtualenv or
    ruby’s rvm, there are nave and
    nvm for node
•   Let’s use nave
• Allows us to have a “stable” environment
• Allows us to test newer versions without risking
managing versions-nave
•   Again, node.js and its libraries move fast
• Like python’s virtualenv or ruby’s rvm, there are
    nave and nvm for node

•   Let’s use nave
•   Allows us to have a “stable” environment
• Allows us to test newer versions without risking
    “stable”
managing versions-nave
•   Again, node.js and its libraries move fast
• Like python’s virtualenv or ruby’s rvm, there are
    nave and nvm for node
•   Let’s use nave

•   Allows us to have a “stable”
    environment
•   Allows us to test newer versions without risking
    “stable”
managing versions-nave
•   Again, node.js and its libraries move fast
• Like python’s virtualenv or ruby’s rvm, there are
    nave and nvm for node
•   Let’s use nave
• Allows us to have a “stable” environment

•   Allows us to test newer
    versions without risking “stable”
install node.js via nave
•   node.js must be built from
    source
•   nave handles this for you. Examples:
      nave use stable
      nave use latest
      nave use 0.4.6

• nave downloads, builds, and installs the node version
    you asked for!
install node.js via nave
•   node.js must be built from source

•   nave handles this for you.
    Examples:
      nave use stable
      nave use latest
      nave use 0.4.6

•   nave downloads, builds, and installs the node version
    you asked for!
install node.js via nave
•   node.js must be built from source
• nave handles this for you. Examples:
      nave use stable
      nave use latest
      nave use 0.4.6


•   nave downloads, builds, and installs
    the node version you asked for!
installing nave
• Adapted from https://gist.github.com/
  579814#file_use_nave.sh
    mkdir ~/.nave
    pushd ~/.nave
    wget http://github.com/isaacs/nave/raw/master/
    nave.sh
    ln -s $PWD/nave.sh ~/local/bin/nave
nave installing a version...


Several thousand lines of build output deleted...
npm: node package manager
•   Handles easy installation of node
    packages
• Databases: mysql, postgresql, sqlite, mongodb, etc
• DOM: jsdom
• web frameworks: e.g. express, connect, spark/spark2
• DOM manipulation: YUI3, jQuery
• Utility libraries: backbone/spine, underscore, socket.io
• Templating: mustache, handlebars, ejs, etc
• Testing: vows, expresso, nodemock, nodeunit
npm: node package manager
• Handles easy installation of node packages
• Databases: mysql, postgresql, sqlite, mongodb, etc
• DOM: jsdom
• web frameworks: e.g. express, connect, spark/spark2
• DOM manipulation:YUI3, jQuery
• Utility libraries: backbone/spine, underscore,
  socket.io
• Templating: mustache, handlebars, ejs, etc
• Testing: vows, expresso, nodemock, nodeunit
install npm
curl http://npmjs.org/install.sh | sh




          That’s it, there is no step 2!
it’s alive
jonathan@ubuntu:~$ node --version
v0.4.7
jonathan@ubuntu:~$ npm --version
1.0.3
jonathan@ubuntu:~$
let’s write a web app
var sys = require('sys'),
  http = require('http');


http.createServer(function(req, res) {
     res.writeHead(200, {'Content-Type': 'text/html'});
     res.write('<h1>Hello World</h1>');
     res.end();
}).listen(8000);


sys.puts('Server running at http://127.0.0.1:8000/');
//https://github.com/jonathana/dcjq_5_nodejs/blob/master/helloworld.js
let’s run the web app
  jonathan@ubuntu:~/src/dcjq_5_nodejs$ nave use stable
  Already installed: 0.4.7
  using 0.4.7
  jonathan@ubuntu:~/src/dcjq_5_nodejs$ PATH=$PATH:`npm
  bin`
  jonathan@ubuntu:~/src/dcjq_5_nodejs$ node
  helloworld.js
  Server running at http://0.0.0.0:8000/

• That PATH= command is for npm-installed executables
and visit our webpage
now let’s debug the web app
•   node-inspector is an npm package for debugging node over http!
    jonathan@ubuntu:~/src/dcjq_5_nodejs$ node-inspector &
    [1] 6274
    visit http://0.0.0.0:8080/debug?port=5858 to start debugging
    jonathan@ubuntu:~/src/dcjq_5_nodejs$ node --debug
    helloworld.js
    debugger listening on port 5858
    Server running at http://0.0.0.0:8000/

•   The webkit javascript debugging engine works really well with this.
    Debugging in Chrome FTW!
and see us stop at a breakpoint!
advantages of node
•   Javascript makes callback-based
    (“event”) programming familiar
• Fast: framework says take operations that normally block
    webserver and make them asynchronous
• Same language on client and server
• Same libraries on client and server
• Long-running connections to lots of clients: Comet
advantages of node
• Javascript makes callback-based (“event”) programming familiar
• Fast: framework says take operations
  that normally block webserver and
  make them asynchronous
• Same language on client and server
• Same libraries on client and server
• Long-running connections to lots of clients: Comet
advantages of node
• Javascript makes callback-based (“event”) programming familiar
• Fast: framework says take operations that normally block
    webserver and make them asynchronous

•   Same language on client and server
• Same libraries on client and server
• Long-running connections to lots of clients: Comet
advantages of node
• Javascript makes callback-based (“event”) programming familiar
• Fast: framework says take operations that normally block
    webserver and make them asynchronous
• Same language on client and server
• Same libraries on client and server
• Long-running connections to lots of clients: Comet
advantages of node
• Javascript makes callback-based (“event”) programming familiar
• Fast: framework says take operations that normally block
    webserver and make them asynchronous
• Same language on client and server
• Same libraries on client and server

• Long-running connections to lots of
  clients: Comet
installing node packages


    Some more output deleted...
sample web development stack
 •   node-inspector: debugging
 •   express (and connect): web framework, middleware, routing, controllers
 •   spark2: nice front-end for controlling node servers
 •   ejs templates: embedded javascript, for views
 •   connect-mongodb: mongoDB-backed sessions
 •   mongoose: mongoDB-based object mapper for models
 •   test: yeah, you should pick some packages and use them
 •   jsdom: manipulate html DOMs server-side
 •   jquery and/or YUI3: do cool stuff server side with the DOM
Examples/Sample App
• See https://github.com/jonathana/dcjq_5_nodejs for the
  example code used in this presentation and a heavily-
  commented simple web app built using many of the
  packages on the previous slides
appendix: Resources
•   Ryan Dahl: (http://tinyclouds.org/, https://github.com/ry)
•   Ryan’s jsconf 2009 presentation: http://s3.amazonaws.com/four.livejournal/
    20091117/jsconf.pdf
•   Simon Willison’s blog post re: node.js: http://simonwillison.net/2009/Nov/23/node/
•   node.js home: http://nodejs.org/, git repo: https://github.com/joyent/node/

•   node modules: https://github.com/joyent/node/wiki/modules
•   Isaac Schlueter: (npm and nave) https://github.com/isaacs/, http://blog.izs.me/
•   Dav Glass’ mind-bending demonstration of using YUI server-side: http://
    developer.yahoo.com/yui/theater/video.php?v=glass-node
•   Nice list of some apps built using node.js + express: http://expressjs.com/
    applications.html

Recommended

Mongo and node mongo dc 2011
Mongo and node mongo dc 2011Mongo and node mongo dc 2011
Mongo and node mongo dc 2011async_io
 
Node.js, toy or power tool?
Node.js, toy or power tool?Node.js, toy or power tool?
Node.js, toy or power tool?Ovidiu Dimulescu
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaNurul Ferdous
 
The State of WebSockets in Django
The State of WebSockets in DjangoThe State of WebSockets in Django
The State of WebSockets in DjangoRami Sayar
 
Vert.x – The problem of real-time data binding
Vert.x – The problem of real-time data bindingVert.x – The problem of real-time data binding
Vert.x – The problem of real-time data bindingAlex Derkach
 
Deploying WO on Windows
Deploying WO on WindowsDeploying WO on Windows
Deploying WO on WindowsWO Community
 
ASFWS 2012 - Node.js Security – Old vulnerabilities in new dresses par Sven V...
ASFWS 2012 - Node.js Security – Old vulnerabilities in new dresses par Sven V...ASFWS 2012 - Node.js Security – Old vulnerabilities in new dresses par Sven V...
ASFWS 2012 - Node.js Security – Old vulnerabilities in new dresses par Sven V...Cyber Security Alliance
 
MySQL DevOps at Outbrain
MySQL DevOps at OutbrainMySQL DevOps at Outbrain
MySQL DevOps at OutbrainShlomi Noach
 

More Related Content

What's hot

PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentIrfan Maulana
 
Node.js 101 with Rami Sayar
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami SayarFITC
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureColin Mackay
 
The elastic stack on docker
The elastic stack on dockerThe elastic stack on docker
The elastic stack on dockerSmartWave
 
Afrimadoni the power of docker
Afrimadoni   the power of dockerAfrimadoni   the power of docker
Afrimadoni the power of dockerPHP Indonesia
 
Node4J: Running Node.js in a JavaWorld
Node4J: Running Node.js in a JavaWorldNode4J: Running Node.js in a JavaWorld
Node4J: Running Node.js in a JavaWorldIan Bull
 
Scaling and securing node.js apps
Scaling and securing node.js appsScaling and securing node.js apps
Scaling and securing node.js appsMaciej Lasyk
 
The story of language development
The story of language developmentThe story of language development
The story of language developmentHiroshi SHIBATA
 
Nodejs getting started
Nodejs getting startedNodejs getting started
Nodejs getting startedTriet Ho
 
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeSarah Z
 
Appsec DC - wXf -2010
Appsec DC - wXf  -2010Appsec DC - wXf  -2010
Appsec DC - wXf -2010Chris Gates
 
Oded Coster - Stack Overflow behind the scenes - how it's made - Codemotion M...
Oded Coster - Stack Overflow behind the scenes - how it's made - Codemotion M...Oded Coster - Stack Overflow behind the scenes - how it's made - Codemotion M...
Oded Coster - Stack Overflow behind the scenes - how it's made - Codemotion M...Codemotion
 
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsSymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsPablo Godel
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkAarti Parikh
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)Chris Cowan
 
Xitrum HOWTOs
Xitrum HOWTOsXitrum HOWTOs
Xitrum HOWTOsNgoc Dao
 

What's hot (20)

PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
 
Node.js 101 with Rami Sayar
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami Sayar
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azure
 
The elastic stack on docker
The elastic stack on dockerThe elastic stack on docker
The elastic stack on docker
 
Afrimadoni the power of docker
Afrimadoni   the power of dockerAfrimadoni   the power of docker
Afrimadoni the power of docker
 
Node4J: Running Node.js in a JavaWorld
Node4J: Running Node.js in a JavaWorldNode4J: Running Node.js in a JavaWorld
Node4J: Running Node.js in a JavaWorld
 
Vert.x
Vert.xVert.x
Vert.x
 
Scaling and securing node.js apps
Scaling and securing node.js appsScaling and securing node.js apps
Scaling and securing node.js apps
 
The story of language development
The story of language developmentThe story of language development
The story of language development
 
Nodejs getting started
Nodejs getting startedNodejs getting started
Nodejs getting started
 
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less Coffee
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Appsec DC - wXf -2010
Appsec DC - wXf  -2010Appsec DC - wXf  -2010
Appsec DC - wXf -2010
 
Lisp in the Cloud
Lisp in the CloudLisp in the Cloud
Lisp in the Cloud
 
Oded Coster - Stack Overflow behind the scenes - how it's made - Codemotion M...
Oded Coster - Stack Overflow behind the scenes - how it's made - Codemotion M...Oded Coster - Stack Overflow behind the scenes - how it's made - Codemotion M...
Oded Coster - Stack Overflow behind the scenes - how it's made - Codemotion M...
 
Csp and http headers
Csp and http headersCsp and http headers
Csp and http headers
 
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsSymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talk
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)
 
Xitrum HOWTOs
Xitrum HOWTOsXitrum HOWTOs
Xitrum HOWTOs
 

Viewers also liked

Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to NodejsGabriele Lana
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
NOVA MEAN - Why the M in MEAN is a Significant Contributor to Its Success
NOVA MEAN - Why the M in MEAN is a Significant Contributor to Its SuccessNOVA MEAN - Why the M in MEAN is a Significant Contributor to Its Success
NOVA MEAN - Why the M in MEAN is a Significant Contributor to Its Successasync_io
 
Guide to AngularJS Services - NOVA MEAN August 2014
Guide to AngularJS Services - NOVA MEAN August 2014Guide to AngularJS Services - NOVA MEAN August 2014
Guide to AngularJS Services - NOVA MEAN August 2014async_io
 
Building a Cauldron for Chef to Cook In
Building a Cauldron for Chef to Cook InBuilding a Cauldron for Chef to Cook In
Building a Cauldron for Chef to Cook Inasync_io
 
Using Jython To Prototype Mahout Code
Using Jython To Prototype Mahout CodeUsing Jython To Prototype Mahout Code
Using Jython To Prototype Mahout Codeasync_io
 
Building Killer RESTful APIs with NodeJs
Building Killer RESTful APIs with NodeJsBuilding Killer RESTful APIs with NodeJs
Building Killer RESTful APIs with NodeJsSrdjan Strbanovic
 
Using npm to Manage Your Projects for Fun and Profit - USEFUL INFO IN NOTES!
Using npm to Manage Your Projects for Fun and Profit - USEFUL INFO IN NOTES!Using npm to Manage Your Projects for Fun and Profit - USEFUL INFO IN NOTES!
Using npm to Manage Your Projects for Fun and Profit - USEFUL INFO IN NOTES!async_io
 
Lessons Learned from Building a REST API on Google App Engine
Lessons Learned from Building a REST API on Google App EngineLessons Learned from Building a REST API on Google App Engine
Lessons Learned from Building a REST API on Google App Engineasync_io
 
Javascript Promises/Q Library
Javascript Promises/Q LibraryJavascript Promises/Q Library
Javascript Promises/Q Libraryasync_io
 
Node js presentation
Node js presentationNode js presentation
Node js presentationmartincabrera
 

Viewers also liked (16)

Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to Nodejs
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
harry presentation
harry presentationharry presentation
harry presentation
 
NOVA MEAN - Why the M in MEAN is a Significant Contributor to Its Success
NOVA MEAN - Why the M in MEAN is a Significant Contributor to Its SuccessNOVA MEAN - Why the M in MEAN is a Significant Contributor to Its Success
NOVA MEAN - Why the M in MEAN is a Significant Contributor to Its Success
 
Guide to AngularJS Services - NOVA MEAN August 2014
Guide to AngularJS Services - NOVA MEAN August 2014Guide to AngularJS Services - NOVA MEAN August 2014
Guide to AngularJS Services - NOVA MEAN August 2014
 
Building a Cauldron for Chef to Cook In
Building a Cauldron for Chef to Cook InBuilding a Cauldron for Chef to Cook In
Building a Cauldron for Chef to Cook In
 
Using Jython To Prototype Mahout Code
Using Jython To Prototype Mahout CodeUsing Jython To Prototype Mahout Code
Using Jython To Prototype Mahout Code
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
 
Building Killer RESTful APIs with NodeJs
Building Killer RESTful APIs with NodeJsBuilding Killer RESTful APIs with NodeJs
Building Killer RESTful APIs with NodeJs
 
Using npm to Manage Your Projects for Fun and Profit - USEFUL INFO IN NOTES!
Using npm to Manage Your Projects for Fun and Profit - USEFUL INFO IN NOTES!Using npm to Manage Your Projects for Fun and Profit - USEFUL INFO IN NOTES!
Using npm to Manage Your Projects for Fun and Profit - USEFUL INFO IN NOTES!
 
MongoDB and Node.js
MongoDB and Node.jsMongoDB and Node.js
MongoDB and Node.js
 
Lessons Learned from Building a REST API on Google App Engine
Lessons Learned from Building a REST API on Google App EngineLessons Learned from Building a REST API on Google App Engine
Lessons Learned from Building a REST API on Google App Engine
 
Javascript Promises/Q Library
Javascript Promises/Q LibraryJavascript Promises/Q Library
Javascript Promises/Q Library
 
Node js presentation
Node js presentationNode js presentation
Node js presentation
 
Best node js course
Best node js courseBest node js course
Best node js course
 
reveal.js 3.0.0
reveal.js 3.0.0reveal.js 3.0.0
reveal.js 3.0.0
 

Similar to Dcjq node.js presentation

Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsasync_io
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jibanJibanananda Sana
 
Leonid Vasilyev "Building, deploying and running production code at Dropbox"
Leonid Vasilyev  "Building, deploying and running production code at Dropbox"Leonid Vasilyev  "Building, deploying and running production code at Dropbox"
Leonid Vasilyev "Building, deploying and running production code at Dropbox"IT Event
 
Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?Christian Joudrey
 
Getting started with developing Nodejs
Getting started with developing NodejsGetting started with developing Nodejs
Getting started with developing NodejsPhil Hawksworth
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2http403
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2Wyatt Fang
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2tianyi5212222
 
Node.js - The New, New Hotness
Node.js - The New, New HotnessNode.js - The New, New Hotness
Node.js - The New, New HotnessDaniel Shaw
 
Linux containers and docker
Linux containers and dockerLinux containers and docker
Linux containers and dockerFabio Fumarola
 
RubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on RailsRubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on Railselliando dias
 
Nodejs Security
Nodejs SecurityNodejs Security
Nodejs SecurityJason Ross
 
Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Ryan Cuprak
 
Overview of Node JS
Overview of Node JSOverview of Node JS
Overview of Node JSJacob Nelson
 
Lions, Tigers and Deers: What building zoos can teach us about securing micro...
Lions, Tigers and Deers: What building zoos can teach us about securing micro...Lions, Tigers and Deers: What building zoos can teach us about securing micro...
Lions, Tigers and Deers: What building zoos can teach us about securing micro...Sysdig
 
Everything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureEverything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureQAware GmbH
 

Similar to Dcjq node.js presentation (20)

Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
 
Leonid Vasilyev "Building, deploying and running production code at Dropbox"
Leonid Vasilyev  "Building, deploying and running production code at Dropbox"Leonid Vasilyev  "Building, deploying and running production code at Dropbox"
Leonid Vasilyev "Building, deploying and running production code at Dropbox"
 
Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Getting started with developing Nodejs
Getting started with developing NodejsGetting started with developing Nodejs
Getting started with developing Nodejs
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2
 
Node.js - The New, New Hotness
Node.js - The New, New HotnessNode.js - The New, New Hotness
Node.js - The New, New Hotness
 
Linux containers and docker
Linux containers and dockerLinux containers and docker
Linux containers and docker
 
RubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on RailsRubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on Rails
 
Nodejs Security
Nodejs SecurityNodejs Security
Nodejs Security
 
Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]
 
Short-Training asp.net vNext
Short-Training asp.net vNextShort-Training asp.net vNext
Short-Training asp.net vNext
 
Overview of Node JS
Overview of Node JSOverview of Node JS
Overview of Node JS
 
Lions, Tigers and Deers: What building zoos can teach us about securing micro...
Lions, Tigers and Deers: What building zoos can teach us about securing micro...Lions, Tigers and Deers: What building zoos can teach us about securing micro...
Lions, Tigers and Deers: What building zoos can teach us about securing micro...
 
OpenStack Summit
OpenStack SummitOpenStack Summit
OpenStack Summit
 
Everything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureEverything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventure
 

Recently uploaded

Python For Kids - Sách Lập trình cho trẻ em
Python For Kids - Sách Lập trình cho trẻ emPython For Kids - Sách Lập trình cho trẻ em
Python For Kids - Sách Lập trình cho trẻ emNho Vĩnh
 
National Institute of Standards and Technology (NIST) Cybersecurity Framework...
National Institute of Standards and Technology (NIST) Cybersecurity Framework...National Institute of Standards and Technology (NIST) Cybersecurity Framework...
National Institute of Standards and Technology (NIST) Cybersecurity Framework...MichaelBenis1
 
VM Migration from VMware to CloudStack and KVM – Suresh Anaparti, ShapeBlue
VM Migration from VMware to CloudStack and KVM – Suresh Anaparti, ShapeBlueVM Migration from VMware to CloudStack and KVM – Suresh Anaparti, ShapeBlue
VM Migration from VMware to CloudStack and KVM – Suresh Anaparti, ShapeBlueShapeBlue
 
My Journey towards Artificial Intelligence
My Journey towards Artificial IntelligenceMy Journey towards Artificial Intelligence
My Journey towards Artificial IntelligenceVijayananda Mohire
 
AMER Introduction to ThousandEyes Webinar
AMER Introduction to ThousandEyes WebinarAMER Introduction to ThousandEyes Webinar
AMER Introduction to ThousandEyes WebinarThousandEyes
 
Achieving Excellence IESVE for HVAC Simulation.pdf
Achieving Excellence IESVE for HVAC Simulation.pdfAchieving Excellence IESVE for HVAC Simulation.pdf
Achieving Excellence IESVE for HVAC Simulation.pdfIES VE
 
Mastering Play Store App Listing and Optimization
Mastering Play Store App Listing and OptimizationMastering Play Store App Listing and Optimization
Mastering Play Store App Listing and OptimizationAppsthentic Technology
 
Establishing data sharing standards to promote global industry development
Establishing data sharing standards to promote global industry developmentEstablishing data sharing standards to promote global industry development
Establishing data sharing standards to promote global industry developmentThorsten Huelsmann
 
Q4 2023 Quarterly Investor Presentation - FINAL.pdf
Q4 2023 Quarterly Investor Presentation - FINAL.pdfQ4 2023 Quarterly Investor Presentation - FINAL.pdf
Q4 2023 Quarterly Investor Presentation - FINAL.pdfTejal81
 
AI improves software testing to be more fault tolerant, focused and efficient
AI improves software testing to be more fault tolerant, focused and efficientAI improves software testing to be more fault tolerant, focused and efficient
AI improves software testing to be more fault tolerant, focused and efficientKari Kakkonen
 
iOncologi_Pitch Deck_2024 slide show for hostinger
iOncologi_Pitch Deck_2024 slide show for hostingeriOncologi_Pitch Deck_2024 slide show for hostinger
iOncologi_Pitch Deck_2024 slide show for hostingerssuser9354ce
 
Transcript: Trending now: Book subjects on the move in the Canadian market - ...
Transcript: Trending now: Book subjects on the move in the Canadian market - ...Transcript: Trending now: Book subjects on the move in the Canadian market - ...
Transcript: Trending now: Book subjects on the move in the Canadian market - ...BookNet Canada
 
eXtended Reality(XR) Basic introductions
eXtended Reality(XR) Basic introductionseXtended Reality(XR) Basic introductions
eXtended Reality(XR) Basic introductionsElanthirayan Madhavan
 
Microsoft x 2toLead Webinar Session 1 - How Employee Communication and Connec...
Microsoft x 2toLead Webinar Session 1 - How Employee Communication and Connec...Microsoft x 2toLead Webinar Session 1 - How Employee Communication and Connec...
Microsoft x 2toLead Webinar Session 1 - How Employee Communication and Connec...2toLead Limited
 
Why Disability Justice should be at the core of your digital accessibility jo...
Why Disability Justice should be at the core of your digital accessibility jo...Why Disability Justice should be at the core of your digital accessibility jo...
Why Disability Justice should be at the core of your digital accessibility jo...Modality Co
 
Low Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & PitfallsLow Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & PitfallsScyllaDB
 
Learning About GenAI Engineering with AWS PartyRock [AWS User Group Basel - F...
Learning About GenAI Engineering with AWS PartyRock [AWS User Group Basel - F...Learning About GenAI Engineering with AWS PartyRock [AWS User Group Basel - F...
Learning About GenAI Engineering with AWS PartyRock [AWS User Group Basel - F...Chris Bingham
 
AGFM - Toyota Coaster 1HZ Install Guide.pdf
AGFM - Toyota Coaster 1HZ Install Guide.pdfAGFM - Toyota Coaster 1HZ Install Guide.pdf
AGFM - Toyota Coaster 1HZ Install Guide.pdfRodneyThomas28
 
Trading Software Development_ Trends to Watch in 2024.pdf
Trading Software Development_ Trends to Watch in 2024.pdfTrading Software Development_ Trends to Watch in 2024.pdf
Trading Software Development_ Trends to Watch in 2024.pdfLucas Lagone
 
CloudStack 101: The Best Way to Build Your Private Cloud – Rohit Yadav, VP Ap...
CloudStack 101: The Best Way to Build Your Private Cloud – Rohit Yadav, VP Ap...CloudStack 101: The Best Way to Build Your Private Cloud – Rohit Yadav, VP Ap...
CloudStack 101: The Best Way to Build Your Private Cloud – Rohit Yadav, VP Ap...ShapeBlue
 

Recently uploaded (20)

Python For Kids - Sách Lập trình cho trẻ em
Python For Kids - Sách Lập trình cho trẻ emPython For Kids - Sách Lập trình cho trẻ em
Python For Kids - Sách Lập trình cho trẻ em
 
National Institute of Standards and Technology (NIST) Cybersecurity Framework...
National Institute of Standards and Technology (NIST) Cybersecurity Framework...National Institute of Standards and Technology (NIST) Cybersecurity Framework...
National Institute of Standards and Technology (NIST) Cybersecurity Framework...
 
VM Migration from VMware to CloudStack and KVM – Suresh Anaparti, ShapeBlue
VM Migration from VMware to CloudStack and KVM – Suresh Anaparti, ShapeBlueVM Migration from VMware to CloudStack and KVM – Suresh Anaparti, ShapeBlue
VM Migration from VMware to CloudStack and KVM – Suresh Anaparti, ShapeBlue
 
My Journey towards Artificial Intelligence
My Journey towards Artificial IntelligenceMy Journey towards Artificial Intelligence
My Journey towards Artificial Intelligence
 
AMER Introduction to ThousandEyes Webinar
AMER Introduction to ThousandEyes WebinarAMER Introduction to ThousandEyes Webinar
AMER Introduction to ThousandEyes Webinar
 
Achieving Excellence IESVE for HVAC Simulation.pdf
Achieving Excellence IESVE for HVAC Simulation.pdfAchieving Excellence IESVE for HVAC Simulation.pdf
Achieving Excellence IESVE for HVAC Simulation.pdf
 
Mastering Play Store App Listing and Optimization
Mastering Play Store App Listing and OptimizationMastering Play Store App Listing and Optimization
Mastering Play Store App Listing and Optimization
 
Establishing data sharing standards to promote global industry development
Establishing data sharing standards to promote global industry developmentEstablishing data sharing standards to promote global industry development
Establishing data sharing standards to promote global industry development
 
Q4 2023 Quarterly Investor Presentation - FINAL.pdf
Q4 2023 Quarterly Investor Presentation - FINAL.pdfQ4 2023 Quarterly Investor Presentation - FINAL.pdf
Q4 2023 Quarterly Investor Presentation - FINAL.pdf
 
AI improves software testing to be more fault tolerant, focused and efficient
AI improves software testing to be more fault tolerant, focused and efficientAI improves software testing to be more fault tolerant, focused and efficient
AI improves software testing to be more fault tolerant, focused and efficient
 
iOncologi_Pitch Deck_2024 slide show for hostinger
iOncologi_Pitch Deck_2024 slide show for hostingeriOncologi_Pitch Deck_2024 slide show for hostinger
iOncologi_Pitch Deck_2024 slide show for hostinger
 
Transcript: Trending now: Book subjects on the move in the Canadian market - ...
Transcript: Trending now: Book subjects on the move in the Canadian market - ...Transcript: Trending now: Book subjects on the move in the Canadian market - ...
Transcript: Trending now: Book subjects on the move in the Canadian market - ...
 
eXtended Reality(XR) Basic introductions
eXtended Reality(XR) Basic introductionseXtended Reality(XR) Basic introductions
eXtended Reality(XR) Basic introductions
 
Microsoft x 2toLead Webinar Session 1 - How Employee Communication and Connec...
Microsoft x 2toLead Webinar Session 1 - How Employee Communication and Connec...Microsoft x 2toLead Webinar Session 1 - How Employee Communication and Connec...
Microsoft x 2toLead Webinar Session 1 - How Employee Communication and Connec...
 
Why Disability Justice should be at the core of your digital accessibility jo...
Why Disability Justice should be at the core of your digital accessibility jo...Why Disability Justice should be at the core of your digital accessibility jo...
Why Disability Justice should be at the core of your digital accessibility jo...
 
Low Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & PitfallsLow Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & Pitfalls
 
Learning About GenAI Engineering with AWS PartyRock [AWS User Group Basel - F...
Learning About GenAI Engineering with AWS PartyRock [AWS User Group Basel - F...Learning About GenAI Engineering with AWS PartyRock [AWS User Group Basel - F...
Learning About GenAI Engineering with AWS PartyRock [AWS User Group Basel - F...
 
AGFM - Toyota Coaster 1HZ Install Guide.pdf
AGFM - Toyota Coaster 1HZ Install Guide.pdfAGFM - Toyota Coaster 1HZ Install Guide.pdf
AGFM - Toyota Coaster 1HZ Install Guide.pdf
 
Trading Software Development_ Trends to Watch in 2024.pdf
Trading Software Development_ Trends to Watch in 2024.pdfTrading Software Development_ Trends to Watch in 2024.pdf
Trading Software Development_ Trends to Watch in 2024.pdf
 
CloudStack 101: The Best Way to Build Your Private Cloud – Rohit Yadav, VP Ap...
CloudStack 101: The Best Way to Build Your Private Cloud – Rohit Yadav, VP Ap...CloudStack 101: The Best Way to Build Your Private Cloud – Rohit Yadav, VP Ap...
CloudStack 101: The Best Way to Build Your Private Cloud – Rohit Yadav, VP Ap...
 

Dcjq node.js presentation

  • 1. dcjq[5] Node.js: What Is It, How Does It Work, and What Can I Use It For Tomorrow? April 28, 2011 Jonathan Altman http://async.io/ @async_io
  • 2. what we’ll cover • What node is • Why node is the way it is • What you can do with it • Set up a running framework to build web apps • Dissect a simple node web application
  • 3. node.js is: • A non-browser Javascript toolkit/ framework started by Ryan Dahl • Available for *nix-based systems: Linux, OS X, OpenSolaris (and Windows) • Built on top of Google’s V8 Javascript engine • Compatible with many common Javascript libraries out of the box via CommonJS support (http://www.commonjs.org/) • A batteries-included framework: HTTP and socket support baked into the core of the framework • A framework that is easy to build tooling on top of • Most importantly: asynchronous from the ground up
  • 4. node.js is: • A non-browser Javascript toolkit/framework started by Ryan Dahl • Available for *nix-based systems: Linux, OS X, OpenSolaris (and Windows) • Built on top of Google’s V8 Javascript engine • Compatible with many common Javascript libraries out of the box via CommonJS support (http://www.commonjs.org/) • A batteries-included framework: HTTP and socket support baked into the core of the framework • A framework that is easy to build tooling on top of • Most importantly: asynchronous from the ground up
  • 5. node.js is: • A non-browser Javascript toolkit/framework started by Ryan Dahl • Available for *nix-based systems: Linux, OS X, OpenSolaris (and Windows) • Built on top of Google’s V8 Javascript engine • Compatible with many common Javascript libraries out of the box via CommonJS support (http://www.commonjs.org/) • A batteries-included framework: HTTP and socket support baked into the core of the framework • A framework that is easy to build tooling on top of • Most importantly: asynchronous from the ground up
  • 6. node.js is: • A non-browser Javascript toolkit/framework started by Ryan Dahl • Available for *nix-based systems: Linux, OS X, OpenSolaris (and Windows) • Built on top of Google’s V8 Javascript engine • Compatible with many common Javascript libraries out of the box via CommonJS support (http://www.commonjs.org/) • A batteries-included framework: HTTP and socket support baked into the core of the framework • A framework that is easy to build tooling on top of • Most importantly: asynchronous from the ground up
  • 7. node.js is: • A non-browser Javascript toolkit/framework started by Ryan Dahl • Available for *nix-based systems: Linux, OS X, OpenSolaris (and Windows) • Built on top of Google’s V8 Javascript engine • Compatible with many common Javascript libraries out of the box via CommonJS support (http://www.commonjs.org/) • A batteries-included framework: HTTP and socket support baked into the core of the framework • A framework that is easy to build tooling on top of • Most importantly: asynchronous from the ground up
  • 8. node.js is: • A non-browser Javascript toolkit/framework started by Ryan Dahl • Available for *nix-based systems: Linux, OS X, OpenSolaris (and Windows) • Built on top of Google’s V8 Javascript engine • Compatible with many common Javascript libraries out of the box via CommonJS support (http://www.commonjs.org/) • A batteries-included framework: HTTP and socket support baked into the core of the framework • A framework that is easy to build tooling on top of • Most importantly: asynchronous from the ground up
  • 9. node.js is: • A non-browser Javascript toolkit/framework started by Ryan Dahl • Available for *nix-based systems: Linux, OS X, OpenSolaris (and Windows) • Built on top of Google’s V8 Javascript engine • Compatible with many common Javascript libraries out of the box via CommonJS support (http://www.commonjs.org/) • A batteries-included framework: HTTP and socket support baked into the core of the framework • A framework that is easy to build tooling on top of • Most importantly: asynchronous from the ground up
  • 10. so what does code look like?
  • 11. node.js script to determine if a file exists Running it yields:
  • 12. whoa, back up: asynchronous? • Core trait of the framework • Provides scalability • Long-running operations do not block your server • Coding looks odd for server writers
  • 13. whoa, back up: asynchronous? • Core trait of the framework • Provides scalability • Long-running operations do not block your server • Coding looks odd for server writers
  • 14. whoa, back up: asynchronous? • Core trait of the framework • Provides scalability • Long-running operations do not block your server • Coding looks odd for server writers
  • 15. whoa, back up: asynchronous? • Core trait of the framework • Provides scalability • Long-running operations do not block your server • Coding looks odd for server writers
  • 16. code looks odd? • node: • jQuery: var sys = require('sys'), $('.station_map').live("pagecreate", function() { path = require('path'),     if(navigator.geolocation) { fs = require('fs');       navigator.geolocation.getCurrentPosition(function(position){         initializeMap(position.coords.latitude,position.coords.longit var fileName = process.ARGV[2]; ude); path.exists(fileName, function(exists) {       }); if (!exists) {     } sys.puts(fileName + ' not found');   }); return; // snippet taken from https://github.com/mikeymckay/Capital- } Bikeshare/blob/master/capitalbikeshare.js sys.puts('w00t! ' + fileName + ' exists!'); }); // https://github.com/jonathana/dcjq_5_nodejs/blob/master/ node_async_example.js Doesn’t the code look just like the event-driven javascript DHTML- based web apps have been written in for years?
  • 17. node: up and running • node.js and its ecosystem still evolves very fast • Highly recommended to not put any of it in your system paths • We’ll use ~/local (lots of examples do so...)
  • 18. node: up and running • node.js and its ecosystem still evolves very fast • Highly recommended to not put any of it in your system paths • We’ll use ~/local (lots of examples do so...)
  • 19. node: up and running • node.js and its ecosystem still evolves very fast • Highly recommended to not put any of it in your system paths • We’ll use ~/local (lots of examples do so...)
  • 20. be careful for: • Highly recommended not to install node in “system” locations yet • Uncertain security/threat model • Hide behind a reverse proxy
  • 21. be careful for: • Highly recommended not to install node in “system” locations yet • Uncertain security/threat model • Hide behind a reverse proxy
  • 22. be careful for: • Highly recommended not to install node in “system” locations yet • Uncertain security/threat model • Hide behind a reverse proxy
  • 23. be careful for: • Highly recommended not to install node in “system” locations yet • Uncertain security/threat model • Hide behind a reverse proxy • Everything in this presentation could be wrong by now!
  • 24. basic components • node.js itself • nave: manages multiple versions of node • npm: node package manager. Like ruby’s gem or python’s easy_install
  • 25. basic components • node.js itself • nave: manages multiple versions of node • npm: node package manager. Like ruby’s gem or python’s easy_install
  • 26. basic components • node.js itself • nave: manages multiple versions of node • npm: node package manager. Like ruby’s gem or python’s easy_install
  • 27. managing versions-nave • Again, node.js and its libraries move fast • Like python’s virtualenv or ruby’s rvm, there are nave and nvm for node • Let’s use nave • Allows us to have a “stable” environment • Allows us to test newer versions without risking “stable”
  • 28. managing versions-nave • Again, node.js and its libraries move fast • Like python’s virtualenv or ruby’s rvm, there are nave and nvm for node • Let’s use nave • Allows us to have a “stable” environment • Allows us to test newer versions without risking
  • 29. managing versions-nave • Again, node.js and its libraries move fast • Like python’s virtualenv or ruby’s rvm, there are nave and nvm for node • Let’s use nave • Allows us to have a “stable” environment • Allows us to test newer versions without risking “stable”
  • 30. managing versions-nave • Again, node.js and its libraries move fast • Like python’s virtualenv or ruby’s rvm, there are nave and nvm for node • Let’s use nave • Allows us to have a “stable” environment • Allows us to test newer versions without risking “stable”
  • 31. managing versions-nave • Again, node.js and its libraries move fast • Like python’s virtualenv or ruby’s rvm, there are nave and nvm for node • Let’s use nave • Allows us to have a “stable” environment • Allows us to test newer versions without risking “stable”
  • 32. install node.js via nave • node.js must be built from source • nave handles this for you. Examples: nave use stable nave use latest nave use 0.4.6 • nave downloads, builds, and installs the node version you asked for!
  • 33. install node.js via nave • node.js must be built from source • nave handles this for you. Examples: nave use stable nave use latest nave use 0.4.6 • nave downloads, builds, and installs the node version you asked for!
  • 34. install node.js via nave • node.js must be built from source • nave handles this for you. Examples: nave use stable nave use latest nave use 0.4.6 • nave downloads, builds, and installs the node version you asked for!
  • 35. installing nave • Adapted from https://gist.github.com/ 579814#file_use_nave.sh mkdir ~/.nave pushd ~/.nave wget http://github.com/isaacs/nave/raw/master/ nave.sh ln -s $PWD/nave.sh ~/local/bin/nave
  • 36. nave installing a version... Several thousand lines of build output deleted...
  • 37. npm: node package manager • Handles easy installation of node packages • Databases: mysql, postgresql, sqlite, mongodb, etc • DOM: jsdom • web frameworks: e.g. express, connect, spark/spark2 • DOM manipulation: YUI3, jQuery • Utility libraries: backbone/spine, underscore, socket.io • Templating: mustache, handlebars, ejs, etc • Testing: vows, expresso, nodemock, nodeunit
  • 38. npm: node package manager • Handles easy installation of node packages • Databases: mysql, postgresql, sqlite, mongodb, etc • DOM: jsdom • web frameworks: e.g. express, connect, spark/spark2 • DOM manipulation:YUI3, jQuery • Utility libraries: backbone/spine, underscore, socket.io • Templating: mustache, handlebars, ejs, etc • Testing: vows, expresso, nodemock, nodeunit
  • 39. install npm curl http://npmjs.org/install.sh | sh That’s it, there is no step 2!
  • 40. it’s alive jonathan@ubuntu:~$ node --version v0.4.7 jonathan@ubuntu:~$ npm --version 1.0.3 jonathan@ubuntu:~$
  • 41. let’s write a web app var sys = require('sys'), http = require('http'); http.createServer(function(req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.write('<h1>Hello World</h1>'); res.end(); }).listen(8000); sys.puts('Server running at http://127.0.0.1:8000/'); //https://github.com/jonathana/dcjq_5_nodejs/blob/master/helloworld.js
  • 42. let’s run the web app jonathan@ubuntu:~/src/dcjq_5_nodejs$ nave use stable Already installed: 0.4.7 using 0.4.7 jonathan@ubuntu:~/src/dcjq_5_nodejs$ PATH=$PATH:`npm bin` jonathan@ubuntu:~/src/dcjq_5_nodejs$ node helloworld.js Server running at http://0.0.0.0:8000/ • That PATH= command is for npm-installed executables
  • 43. and visit our webpage
  • 44. now let’s debug the web app • node-inspector is an npm package for debugging node over http! jonathan@ubuntu:~/src/dcjq_5_nodejs$ node-inspector & [1] 6274 visit http://0.0.0.0:8080/debug?port=5858 to start debugging jonathan@ubuntu:~/src/dcjq_5_nodejs$ node --debug helloworld.js debugger listening on port 5858 Server running at http://0.0.0.0:8000/ • The webkit javascript debugging engine works really well with this. Debugging in Chrome FTW!
  • 45. and see us stop at a breakpoint!
  • 46. advantages of node • Javascript makes callback-based (“event”) programming familiar • Fast: framework says take operations that normally block webserver and make them asynchronous • Same language on client and server • Same libraries on client and server • Long-running connections to lots of clients: Comet
  • 47. advantages of node • Javascript makes callback-based (“event”) programming familiar • Fast: framework says take operations that normally block webserver and make them asynchronous • Same language on client and server • Same libraries on client and server • Long-running connections to lots of clients: Comet
  • 48. advantages of node • Javascript makes callback-based (“event”) programming familiar • Fast: framework says take operations that normally block webserver and make them asynchronous • Same language on client and server • Same libraries on client and server • Long-running connections to lots of clients: Comet
  • 49. advantages of node • Javascript makes callback-based (“event”) programming familiar • Fast: framework says take operations that normally block webserver and make them asynchronous • Same language on client and server • Same libraries on client and server • Long-running connections to lots of clients: Comet
  • 50. advantages of node • Javascript makes callback-based (“event”) programming familiar • Fast: framework says take operations that normally block webserver and make them asynchronous • Same language on client and server • Same libraries on client and server • Long-running connections to lots of clients: Comet
  • 51. installing node packages Some more output deleted...
  • 52. sample web development stack • node-inspector: debugging • express (and connect): web framework, middleware, routing, controllers • spark2: nice front-end for controlling node servers • ejs templates: embedded javascript, for views • connect-mongodb: mongoDB-backed sessions • mongoose: mongoDB-based object mapper for models • test: yeah, you should pick some packages and use them • jsdom: manipulate html DOMs server-side • jquery and/or YUI3: do cool stuff server side with the DOM
  • 53. Examples/Sample App • See https://github.com/jonathana/dcjq_5_nodejs for the example code used in this presentation and a heavily- commented simple web app built using many of the packages on the previous slides
  • 54. appendix: Resources • Ryan Dahl: (http://tinyclouds.org/, https://github.com/ry) • Ryan’s jsconf 2009 presentation: http://s3.amazonaws.com/four.livejournal/ 20091117/jsconf.pdf • Simon Willison’s blog post re: node.js: http://simonwillison.net/2009/Nov/23/node/ • node.js home: http://nodejs.org/, git repo: https://github.com/joyent/node/ • node modules: https://github.com/joyent/node/wiki/modules • Isaac Schlueter: (npm and nave) https://github.com/isaacs/, http://blog.izs.me/ • Dav Glass’ mind-bending demonstration of using YUI server-side: http:// developer.yahoo.com/yui/theater/video.php?v=glass-node • Nice list of some apps built using node.js + express: http://expressjs.com/ applications.html

Editor's Notes

  1. \n
  2. \n
  3. \n\n
  4. \n\n
  5. \n\n
  6. \n\n
  7. \n\n\n
  8. \n\n\n\n
  9. \n\n\n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n\n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n\n
  47. \n\n
  48. \n\n
  49. \n\n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n