ݺߣ

ݺߣShare a Scribd company logo
Un progetto di  Ryan Dahl Una presentazione di Eugenio Pombi NetMeansNet s.n.c.
Node.js è Server-side JavaScript interpreter Scritto in C++ Event driven (non blocking I/O)
$result  = mysql_query( 'SELECT * WHERE 1=1' ); //do something Cosa fa apache mentre vengono recuperati i dati in attesa di essere mostrati?
Aspetta... E tiene impegnate risorse hardware nell'attesa (RAM e CPU) Apache apre un thread per ogni nuova connessione
$result  = mysql_query( 'SELECT * WHERE 1=1' ); //do something l'intero processo si blocca durante l'attesa Oppure Multiple execution stacks Questo codice implica che
db.query( 'SELECT * WHERE 1=1' , function( result ){ //do something }) ; Questo codice permette di tornare all'event loop liberando le risorse Event Loop Javascript evented programming
//server.js var  sys = require(  "util"  ), http = require(  "http"  ); http. createServer (  function ( request, response ) { response. writeHead (  200 , { "Content-Type" :  "text/html" } ); response. write (  "Hello World!"  ); response. close (); }). listen (  8080  ); sys. puts (  "Server running at  http://localhost:8080 "  );
var  sys = require( "util" ), // [...] http, url, path, fs http.createServer( function (request, response) { var  uri = url. parse (request. url ). pathname ; var  filename = path. join (process. cwd (), uri); path. exists (filename,  function (exists) { if(!exists) { response. writeHead ( 404 , { "Content-Type" :  "text/plain" }); response. write (" 404 Not Found\n "); response. end (); return ; } fs. readFile (filename,  "binary" ,  function (err, file) { if(err) { response. writeHead ( 500 , { "Content-Type" :  "text/plain" }); response. write (err +  "\n" ); response. end (); return ; } response. writeHead ( 200 ); response. write (file,  "binary" ); response. end (); }); }); }). listen ( 8080 ); sys. puts ( "Server running at http://localhost:8081/" );
Cosa può fare Leggere cookie Ricevere dati da form  Ricevere dati dalla querystring Gestire gli header Uploadare files File streaming P2P (chat e simili) [...] Sistema modulare (npm)
Framework Express Geddy TDD ready Expresso nodeUnit Consigli Occhio ai tutorial con codice vecchio ;) response. close () > response. end ()  var  sys = require( "sys" ) >  var  util = require( "util" )  http://nodetuts.com http://jsconf.eu/2009/video_nodejs_by_ryan_dahl.html
GRAZIE Eugenio Pombi [email_address] @euxpom [email_address]
Ad

Recommended

Async navigation with a lightweight ES6 framework
Async navigation with a lightweight ES6 framework
sparkfabrik
local::lib
local::lib
Flavio Poletti
Php mysql3
Php mysql3
orestJump
Come si creano le app Android
Come si creano le app Android
Andrea Lazzarotto
Php mysql e cms
Php mysql e cms
orestJump
Pubblicare
Pubblicare
giocoscuola
Amazon S3 in Perl
Amazon S3 in Perl
Flavio Poletti
Corso di php01
Corso di php01
Emilia Calzetta
breve introduzione a node.js
breve introduzione a node.js
netmeansnet
Rich Ajax Web Interfaces in Jquery
Rich Ajax Web Interfaces in Jquery
Alberto Buschettu
Progetto di Basi di Dati
Progetto di Basi di Dati
segarva
Consigli per iniziare tdd
Consigli per iniziare tdd
Tassoman ☺
Sviluppo web dall'antichità all'avanguardia e ritorno
Sviluppo web dall'antichità all'avanguardia e ritorno
lordarthas
jQuery e i suoi plugin
jQuery e i suoi plugin
Pasquale Puzio
node.js e Postgresql
node.js e Postgresql
Lucio Grenzi
Primo Incontro Con Scala
Primo Incontro Con Scala
Franco Lombardo
Web Performance Optimization
Web Performance Optimization
Alessandro Martin
Java Advanced
Java Advanced
Antonio Furone
Ajax
Ajax
davide ficano
Write less do more...with jQuery
Write less do more...with jQuery
XeDotNet
JAMP DAY 2010 - ROMA (4)
JAMP DAY 2010 - ROMA (4)
jampslide
Come sviluppo le applicazioni web
Come sviluppo le applicazioni web
Andrea Lazzarotto
Applicazioni native in java
Applicazioni native in java
Federico Paparoni
Abusing HTML 5 Client-side Storage
Abusing HTML 5 Client-side Storage
ameft
JAMP DAY 2010 - ROMA (3)
JAMP DAY 2010 - ROMA (3)
jampslide
Js intro
Js intro
Daniele Cruciani
Ajax - Presente e futuro delle applicazioni web
Ajax - Presente e futuro delle applicazioni web
Dominopoint - Italian Lotus User Group
Php e mysql (primi passi)
Php e mysql (primi passi)
Sergio Roselli ✫✫✫
Parlo al mio codice
Parlo al mio codice
eugenio pombi
Processing one year of leading for Pug roma
Processing one year of leading for Pug roma
eugenio pombi

More Related Content

Similar to breve introduzione a node.js (20)

breve introduzione a node.js
breve introduzione a node.js
netmeansnet
Rich Ajax Web Interfaces in Jquery
Rich Ajax Web Interfaces in Jquery
Alberto Buschettu
Progetto di Basi di Dati
Progetto di Basi di Dati
segarva
Consigli per iniziare tdd
Consigli per iniziare tdd
Tassoman ☺
Sviluppo web dall'antichità all'avanguardia e ritorno
Sviluppo web dall'antichità all'avanguardia e ritorno
lordarthas
jQuery e i suoi plugin
jQuery e i suoi plugin
Pasquale Puzio
node.js e Postgresql
node.js e Postgresql
Lucio Grenzi
Primo Incontro Con Scala
Primo Incontro Con Scala
Franco Lombardo
Web Performance Optimization
Web Performance Optimization
Alessandro Martin
Java Advanced
Java Advanced
Antonio Furone
Ajax
Ajax
davide ficano
Write less do more...with jQuery
Write less do more...with jQuery
XeDotNet
JAMP DAY 2010 - ROMA (4)
JAMP DAY 2010 - ROMA (4)
jampslide
Come sviluppo le applicazioni web
Come sviluppo le applicazioni web
Andrea Lazzarotto
Applicazioni native in java
Applicazioni native in java
Federico Paparoni
Abusing HTML 5 Client-side Storage
Abusing HTML 5 Client-side Storage
ameft
JAMP DAY 2010 - ROMA (3)
JAMP DAY 2010 - ROMA (3)
jampslide
Js intro
Js intro
Daniele Cruciani
Ajax - Presente e futuro delle applicazioni web
Ajax - Presente e futuro delle applicazioni web
Dominopoint - Italian Lotus User Group
Php e mysql (primi passi)
Php e mysql (primi passi)
Sergio Roselli ✫✫✫

More from eugenio pombi (7)

Parlo al mio codice
Parlo al mio codice
eugenio pombi
Processing one year of leading for Pug roma
Processing one year of leading for Pug roma
eugenio pombi
Datagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and Backgrid
eugenio pombi
Codemotion workshop
Codemotion workshop
eugenio pombi
Arduino - il mio primo sketch
Arduino - il mio primo sketch
eugenio pombi
PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2
eugenio pombi
Appetite comes with testing
Appetite comes with testing
eugenio pombi
Processing one year of leading for Pug roma
Processing one year of leading for Pug roma
eugenio pombi
Datagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and Backgrid
eugenio pombi
Arduino - il mio primo sketch
Arduino - il mio primo sketch
eugenio pombi
PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2
eugenio pombi
Appetite comes with testing
Appetite comes with testing
eugenio pombi
Ad

breve introduzione a node.js

  • 1. Un progetto di Ryan Dahl Una presentazione di Eugenio Pombi NetMeansNet s.n.c.
  • 2. Node.js è Server-side JavaScript interpreter Scritto in C++ Event driven (non blocking I/O)
  • 3. $result = mysql_query( 'SELECT * WHERE 1=1' ); //do something Cosa fa apache mentre vengono recuperati i dati in attesa di essere mostrati?
  • 4. Aspetta... E tiene impegnate risorse hardware nell'attesa (RAM e CPU) Apache apre un thread per ogni nuova connessione
  • 5. $result = mysql_query( 'SELECT * WHERE 1=1' ); //do something l'intero processo si blocca durante l'attesa Oppure Multiple execution stacks Questo codice implica che
  • 6. db.query( 'SELECT * WHERE 1=1' , function( result ){ //do something }) ; Questo codice permette di tornare all'event loop liberando le risorse Event Loop Javascript evented programming
  • 7. //server.js var sys = require( "util" ), http = require( "http" ); http. createServer ( function ( request, response ) { response. writeHead ( 200 , { "Content-Type" : "text/html" } ); response. write ( "Hello World!" ); response. close (); }). listen ( 8080 ); sys. puts ( "Server running at http://localhost:8080 " );
  • 8. var sys = require( "util" ), // [...] http, url, path, fs http.createServer( function (request, response) { var uri = url. parse (request. url ). pathname ; var filename = path. join (process. cwd (), uri); path. exists (filename, function (exists) { if(!exists) { response. writeHead ( 404 , { "Content-Type" : "text/plain" }); response. write (" 404 Not Found\n "); response. end (); return ; } fs. readFile (filename, "binary" , function (err, file) { if(err) { response. writeHead ( 500 , { "Content-Type" : "text/plain" }); response. write (err + "\n" ); response. end (); return ; } response. writeHead ( 200 ); response. write (file, "binary" ); response. end (); }); }); }). listen ( 8080 ); sys. puts ( "Server running at http://localhost:8081/" );
  • 9. Cosa può fare Leggere cookie Ricevere dati da form Ricevere dati dalla querystring Gestire gli header Uploadare files File streaming P2P (chat e simili) [...] Sistema modulare (npm)
  • 10. Framework Express Geddy TDD ready Expresso nodeUnit Consigli Occhio ai tutorial con codice vecchio ;) response. close () > response. end () var sys = require( "sys" ) > var util = require( "util" ) http://nodetuts.com http://jsconf.eu/2009/video_nodejs_by_ryan_dahl.html
  • 11. GRAZIE Eugenio Pombi [email_address] @euxpom [email_address]