SlideShare a Scribd company logo
1 of 14
Server side Javascript environment
What is node.js? Why another server side technology? Node.js is a server-side JavaScript environment that uses an asynchronous event-driven model. This allows Node.js to get excellent performance based on the architectures of many Internet applications. Most regular Web Servers like Apache uses OS threads for request handling. That means that every request the server handles will spawn a OS thread and the web server won't release the thread until the request finish. Most of the time OS threads wait till some I/O operation finish: var result = query("select * from users"); for(user in result){      //You get the idea } In this case the OS thread just sits and waits the I/O operation returns to resume the flow. Every OS thread takes some memory, so regular servers can't handle many simultaneous connections without penalizing the system performance.
node.js carachteristics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Alternatives ,[object Object],[object Object]
hands on code: hello world! <?php       //helloworld.php      echo &quot;hello&quot;;      sleep(2);      echo &quot;world!&quot;; ?> //helloworld.js setTimeout(function(){      console.log(&quot;world!&quot;); }, 2000); console.log(&quot;hello&quot;); There is no waisted time on the node program, the thread is idle not waiting
hands on code: http server var http = require(&quot;http&quot;) ; var server = http.createServer(function(req, res){      res.writeHead(200, {&quot;content-type&quot;:&quot;text/plain&quot;});      res.end(&quot;Hello World!&quot;); }).listen(8000); Headers of the request are: HTTP/1.1 200 OK content-type: text/plain Connection: keep-alive Transfer-Encoding: chunked
hands on code: not only http var net = require(&quot;net&quot;) ; net.createServer(function(socket){      socket.on(&quot;data&quot;, function(data){        socket.write(data);      }); }).listen(8000);
hands on code: telnet chat var net = require(&quot;net&quot;); var clients = []; net.createServer(function(socket){    clients.push(socket);         socket.on(&quot;data&quot;, function(data){      for(var i = 0; i < clients.length; i++){              if(clients[i] == socket) continue;        clients[i].write(data);                  }        });         socket.on(&quot;end&quot;, function(){      var index = clients.indexOf(socket);      clients.splice(index, 1);    });   }).listen(8000);
hands on code: Async I/O var fs = require(&quot;fs&quot;)    , sys = require(&quot;sys&quot;);; fs.readFile(&quot;/home/cherta/workspace/samples/foo.txt&quot;, function(err, data){      if(err) throw err;      sys.puts(data) }); console.log(&quot;Antes de foo?&quot;);
What is node.js? It's a set of tools and libraries living on top of the V8. What is not node.js? A super framework that would change your life. Assuming that your life will change for a crappy piece of software
Working on top of node There are killer frameworks that will make your life easier using node. ,[object Object],[object Object]
Express ,[object Object],[object Object],[object Object],[object Object],[object Object],var app = express.createServer(); app.get('/', function(req, res){      res.send('Hello World'); }); app.listen(3000);
Socket I/O Socket.IO is a Node.JS project that makes WebSockets and realtime possible in all browsers. It also enhances WebSockets by providing built-in multiplexing, horizontal scalability, automatic JSON encoding/decoding, and more.
gracias

More Related Content

What's hot

Use Node.js to create a REST API
Use Node.js to create a REST APIUse Node.js to create a REST API
Use Node.js to create a REST APIFabien Vauchelles
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node jsAkshay Mathur
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.jsDinesh U
 
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaSanjeev Tripathi
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js ExpressEyal Vardi
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript BasicsMindfire Solutions
 
TypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painTypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painSander Mak (@Sander_Mak)
 
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...Edureka!
 
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...Edureka!
 
What is JavaScript? Edureka
What is JavaScript? EdurekaWhat is JavaScript? Edureka
What is JavaScript? EdurekaEdureka!
 
Introduction into ES6 JavaScript.
Introduction into ES6 JavaScript.Introduction into ES6 JavaScript.
Introduction into ES6 JavaScript.boyney123
 
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Edureka!
 

What's hot (20)

TypeScript - An Introduction
TypeScript - An IntroductionTypeScript - An Introduction
TypeScript - An Introduction
 
Use Node.js to create a REST API
Use Node.js to create a REST APIUse Node.js to create a REST API
Use Node.js to create a REST API
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript Basics
 
TypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painTypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the pain
 
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
 
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
What is JavaScript? Edureka
What is JavaScript? EdurekaWhat is JavaScript? Edureka
What is JavaScript? Edureka
 
Javascript
JavascriptJavascript
Javascript
 
Introduction into ES6 JavaScript.
Introduction into ES6 JavaScript.Introduction into ES6 JavaScript.
Introduction into ES6 JavaScript.
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
 

Viewers also liked

Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to NodejsGabriele Lana
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with ExamplesGabriele Lana
 
Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture AppDynamics
 
Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907NodejsFoundation
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.jsjacekbecela
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.jsRyan Anklam
 
The Enterprise Case for Node.js
The Enterprise Case for Node.jsThe Enterprise Case for Node.js
The Enterprise Case for Node.jsNodejsFoundation
 
Architecting large Node.js applications
Architecting large Node.js applicationsArchitecting large Node.js applications
Architecting large Node.js applicationsSergi Mansilla
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsMarcus Frödin
 
Presentación Juego para el plan ceibal
Presentación Juego para el plan ceibalPresentación Juego para el plan ceibal
Presentación Juego para el plan ceibalmartincabrera
 
UX en proyectos de moove-it
UX en proyectos de moove-itUX en proyectos de moove-it
UX en proyectos de moove-itmartincabrera
 
Node js presentation
Node js presentationNode js presentation
Node js presentationshereefsakr
 
Wait queue
Wait queueWait queue
Wait queueRoy Lee
 
Communication with our_clients
Communication with our_clientsCommunication with our_clients
Communication with our_clientsmartincabrera
 
epoll() - The I/O Hero
epoll() - The I/O Heroepoll() - The I/O Hero
epoll() - The I/O HeroMohsin Hijazee
 
Rules Engine - java(Drools) & ruby(ruleby)
Rules Engine - java(Drools) & ruby(ruleby)Rules Engine - java(Drools) & ruby(ruleby)
Rules Engine - java(Drools) & ruby(ruleby)martincabrera
 

Viewers also liked (20)

Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to Nodejs
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with Examples
 
Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture
 
Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907Node Foundation Membership Overview 20160907
Node Foundation Membership Overview 20160907
 
Node ppt
Node pptNode ppt
Node ppt
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
reveal.js 3.0.0
reveal.js 3.0.0reveal.js 3.0.0
reveal.js 3.0.0
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.js
 
The Enterprise Case for Node.js
The Enterprise Case for Node.jsThe Enterprise Case for Node.js
The Enterprise Case for Node.js
 
Architecting large Node.js applications
Architecting large Node.js applicationsArchitecting large Node.js applications
Architecting large Node.js applications
 
Node.js - Best practices
Node.js  - Best practicesNode.js  - Best practices
Node.js - Best practices
 
Nodejs intro
Nodejs introNodejs intro
Nodejs intro
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.js
 
Presentación Juego para el plan ceibal
Presentación Juego para el plan ceibalPresentación Juego para el plan ceibal
Presentación Juego para el plan ceibal
 
UX en proyectos de moove-it
UX en proyectos de moove-itUX en proyectos de moove-it
UX en proyectos de moove-it
 
Node js presentation
Node js presentationNode js presentation
Node js presentation
 
Wait queue
Wait queueWait queue
Wait queue
 
Communication with our_clients
Communication with our_clientsCommunication with our_clients
Communication with our_clients
 
epoll() - The I/O Hero
epoll() - The I/O Heroepoll() - The I/O Hero
epoll() - The I/O Hero
 
Rules Engine - java(Drools) & ruby(ruleby)
Rules Engine - java(Drools) & ruby(ruleby)Rules Engine - java(Drools) & ruby(ruleby)
Rules Engine - java(Drools) & ruby(ruleby)
 

Similar to Node js presentation

GeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime WebGeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime WebBhagaban Behera
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the wayOleg Podsechin
 
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
 
A slightly advanced introduction to node.js
A slightly advanced introduction to node.jsA slightly advanced introduction to node.js
A slightly advanced introduction to node.jsSudar Muthu
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for RubistsSagiv Ofek
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Visual Engineering
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineRicardo Silva
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPMariano Iglesias
 
The future of server side JavaScript
The future of server side JavaScriptThe future of server side JavaScript
The future of server side JavaScriptOleg Podsechin
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevFelix Geisendörfer
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 

Similar to Node js presentation (20)

GeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime WebGeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime Web
 
node.js - Fast event based web application development
node.js - Fast event based web application developmentnode.js - Fast event based web application development
node.js - Fast event based web application development
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
 
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
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
A slightly advanced introduction to node.js
A slightly advanced introduction to node.jsA slightly advanced introduction to node.js
A slightly advanced introduction to node.js
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for Rubists
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHP
 
The future of server side JavaScript
The future of server side JavaScriptThe future of server side JavaScript
The future of server side JavaScript
 
hacking with node.JS
hacking with node.JShacking with node.JS
hacking with node.JS
 
Nodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredev
 
Node.js
Node.jsNode.js
Node.js
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
AppengineJS
AppengineJSAppengineJS
AppengineJS
 
Proposal
ProposalProposal
Proposal
 

Node js presentation

  • 2. What is node.js? Why another server side technology? Node.js is a server-side JavaScript environment that uses an asynchronous event-driven model. This allows Node.js to get excellent performance based on the architectures of many Internet applications. Most regular Web Servers like Apache uses OS threads for request handling. That means that every request the server handles will spawn a OS thread and the web server won't release the thread until the request finish. Most of the time OS threads wait till some I/O operation finish: var result = query(&quot;select * from users&quot;); for(user in result){      //You get the idea } In this case the OS thread just sits and waits the I/O operation returns to resume the flow. Every OS thread takes some memory, so regular servers can't handle many simultaneous connections without penalizing the system performance.
  • 3.
  • 4.
  • 5. hands on code: hello world! <?php       //helloworld.php      echo &quot;hello&quot;;      sleep(2);      echo &quot;world!&quot;; ?> //helloworld.js setTimeout(function(){      console.log(&quot;world!&quot;); }, 2000); console.log(&quot;hello&quot;); There is no waisted time on the node program, the thread is idle not waiting
  • 6. hands on code: http server var http = require(&quot;http&quot;) ; var server = http.createServer(function(req, res){      res.writeHead(200, {&quot;content-type&quot;:&quot;text/plain&quot;});      res.end(&quot;Hello World!&quot;); }).listen(8000); Headers of the request are: HTTP/1.1 200 OK content-type: text/plain Connection: keep-alive Transfer-Encoding: chunked
  • 7. hands on code: not only http var net = require(&quot;net&quot;) ; net.createServer(function(socket){      socket.on(&quot;data&quot;, function(data){        socket.write(data);      }); }).listen(8000);
  • 8. hands on code: telnet chat var net = require(&quot;net&quot;); var clients = []; net.createServer(function(socket){    clients.push(socket);         socket.on(&quot;data&quot;, function(data){      for(var i = 0; i < clients.length; i++){              if(clients[i] == socket) continue;        clients[i].write(data);                  }        });         socket.on(&quot;end&quot;, function(){      var index = clients.indexOf(socket);      clients.splice(index, 1);    });   }).listen(8000);
  • 9. hands on code: Async I/O var fs = require(&quot;fs&quot;)   , sys = require(&quot;sys&quot;);; fs.readFile(&quot;/home/cherta/workspace/samples/foo.txt&quot;, function(err, data){     if(err) throw err;     sys.puts(data) }); console.log(&quot;Antes de foo?&quot;);
  • 10. What is node.js? It's a set of tools and libraries living on top of the V8. What is not node.js? A super framework that would change your life. Assuming that your life will change for a crappy piece of software
  • 11.
  • 12.
  • 13. Socket I/O Socket.IO is a Node.JS project that makes WebSockets and realtime possible in all browsers. It also enhances WebSockets by providing built-in multiplexing, horizontal scalability, automatic JSON encoding/decoding, and more.