SlideShare una empresa de Scribd logo
1 de 18
Introducing Node.js
About Your Speaker
What Is It?

Server side javascript framework

Written using Google V8 Engine

Uses CommonJS module system

Has the latest and greatest Ecmascript5
features
Non-Blocking I/O

The philosophy behind node.js is that system
interactions should be non-blocking

Instead of this:
var data = fs.readFile('foo.txt')
console.log(data);

This:
fs.readFile('foo.txt', function(data){
console.log(data);
});

This whole operation is asynchronous... my
application doesn't have to wait for the file to be
read in

Using javascript to do this makes it easier to
adopt given the existing knowledge of using
callbacks and listeners on the client side
Event Driven Architecture

This leads to a more event driven approach

Rather than returning something, calls should
try to either
− Call a callback passed in
− Fire events that the caller listens for

Built in event system (EventEmitter)
− emitter.emit('data-recvd', evt)
− emitter.on('data-recvd', function(evt){
});
Ecmascript 5 Features
Ecmascript 5 Features

Array Extras
− Map, reduce, forEach, filter, every, some

JSON

Object Utilities

Object.getOwnPropertyNames

Object.create

Object.defineProperties

Object.getOwnPropertyDescriptor

Immutibility
− Object.freeze, Object.seal
Ecmascript 5 Features

Getters/setters

Function.prototype.bind
− Allows you to create a new function with the
argument(s) pre-set
− Example
function add(a,b){
return a+b;
}
var fivePlus = add.bind(5)
console.log(fivePlus(2)); // prints 7
Examples

Enough talking, let's see some examples
− Some file and process interaction
− A simple webserver
− Reverse proxy
− Websockets
− AMQP to integrate with existing applications
Getting Started

Runs on nix and cygwin (no windows support
yet)

Install the latest stable from nodejs.org
− Sorry, no installer. You'll need to build it
yourself

Try the commandline repl out. If all is well,
you're good to go!

Hack away
npm

Ruby has gem, node has npm (node package
manager)

This is a must have for node.js development
− http://npmjs.org

Quick Install:
− curl http://npmjs.org/install.sh | sh

Can also be used to budle up your application's
dependencies
Modules of Note

Some interesting modules to take note of and
try out
− Express – simple sintatra clone (a dime a
dozen these days)
− Vows – async BDD in javascript
− Socket.IO – websockets made easy
− Yui3 – adaption of YUI for node.js
− SEVERAL NoSQL modules

Riak, redis, couchDB, mongoDB, tokyo cabinet,
etc.
Hosting Options

Heroku (closed beta)

Joyent (open beta)

Nodjitsu (launching soon)

DIY (EC2, your own server, etc)
Cons

Evolving rapidly.
− It's not uncommon to see tutorials from
several months ago that no longer work

Not very cross platform (yet)

Lots of duplicate modules
− Not that this is a bad thing, but for example
there are TEN couchdb modules (because
couchdb wrappers are simple to make)

No clustering support yet
Clustering Support

No real support yet, but it's on the way!
− EventEmitters backed by websockets
− Another using Redis built-in publish/subscribe
mechanisms
− I've been hacking at EventEmitters backed by
AMQP
Users
Join the Community!

irc.freenode.net #node.js

Google Groups node.js

File bugs/suggest features

Use and Contribute!

Más contenido relacionado

La actualidad más candente

OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js Tutorial
Tom Croucher
 

La actualidad más candente (20)

Václav Makeš - Infrastructure as code - Jak nahazovat stroje a nic moc nevědě...
Václav Makeš - Infrastructure as code - Jak nahazovat stroje a nic moc nevědě...Václav Makeš - Infrastructure as code - Jak nahazovat stroje a nic moc nevědě...
Václav Makeš - Infrastructure as code - Jak nahazovat stroje a nic moc nevědě...
 
Node in Real Time - The Beginning
Node in Real Time - The BeginningNode in Real Time - The Beginning
Node in Real Time - The Beginning
 
Ansible & Vagrant
Ansible & VagrantAnsible & Vagrant
Ansible & Vagrant
 
Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDB
 
Построение простого REST сервера на Node.js | Odessa Frontend Code challenge
Построение простого REST сервера на Node.js | Odessa Frontend Code challengeПостроение простого REST сервера на Node.js | Odessa Frontend Code challenge
Построение простого REST сервера на Node.js | Odessa Frontend Code challenge
 
Depende, ¿de qué depende? - Plain Concepts Dev Day
Depende, ¿de qué depende? - Plain Concepts Dev Day Depende, ¿de qué depende? - Plain Concepts Dev Day
Depende, ¿de qué depende? - Plain Concepts Dev Day
 
NodeJS overview
NodeJS overviewNodeJS overview
NodeJS overview
 
Supercharge your next Vue app with Nuxt
Supercharge your next Vue app with NuxtSupercharge your next Vue app with Nuxt
Supercharge your next Vue app with Nuxt
 
Capistrano && SystemD
Capistrano && SystemDCapistrano && SystemD
Capistrano && SystemD
 
Understanding Non Blocking I/O with Python
Understanding Non Blocking I/O with PythonUnderstanding Non Blocking I/O with Python
Understanding Non Blocking I/O with Python
 
Analysis of an exploited npm package
Analysis of an exploited npm packageAnalysis of an exploited npm package
Analysis of an exploited npm package
 
Storage based snapshots for KVM VMs in CloudStack
Storage based snapshots for KVM VMs in CloudStackStorage based snapshots for KVM VMs in CloudStack
Storage based snapshots for KVM VMs in CloudStack
 
Nginx+ Naxsi
Nginx+ NaxsiNginx+ Naxsi
Nginx+ Naxsi
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js Tutorial
 
Introduction to Penetration Testing
Introduction to Penetration TestingIntroduction to Penetration Testing
Introduction to Penetration Testing
 
Quick Introduction to Node.js
Quick Introduction to Node.jsQuick Introduction to Node.js
Quick Introduction to Node.js
 
FreeBSD preseed installation (PXE) AsiaBSDCon 2015
FreeBSD preseed installation (PXE) AsiaBSDCon 2015FreeBSD preseed installation (PXE) AsiaBSDCon 2015
FreeBSD preseed installation (PXE) AsiaBSDCon 2015
 
Deep dive-oz
Deep dive-ozDeep dive-oz
Deep dive-oz
 
Multi-core Node.pdf
Multi-core Node.pdfMulti-core Node.pdf
Multi-core Node.pdf
 

Destacado

Introduction to nodejs
Introduction to nodejsIntroduction to nodejs
Introduction to nodejs
James Carr
 
High powered messaging with RabbitMQ
High powered messaging with RabbitMQHigh powered messaging with RabbitMQ
High powered messaging with RabbitMQ
James Carr
 

Destacado (19)

Policy overview unam 120522
Policy overview unam 120522Policy overview unam 120522
Policy overview unam 120522
 
Palm internationalreport 201000922
Palm internationalreport 201000922Palm internationalreport 201000922
Palm internationalreport 201000922
 
Contextualizing Policy Developments in Open Knowledge in South Africa
Contextualizing  Policy Developments in Open  Knowledge in South AfricaContextualizing  Policy Developments in Open  Knowledge in South Africa
Contextualizing Policy Developments in Open Knowledge in South Africa
 
Portfolio Sculptures 2007
Portfolio Sculptures 2007Portfolio Sculptures 2007
Portfolio Sculptures 2007
 
Publishing Development Research and Adding Value
Publishing Development Research and Adding ValuePublishing Development Research and Adding Value
Publishing Development Research and Adding Value
 
Introduction to nodejs
Introduction to nodejsIntroduction to nodejs
Introduction to nodejs
 
Wsp Deck Games
Wsp Deck GamesWsp Deck Games
Wsp Deck Games
 
Dealing in Disruption - OA policy in an African context
Dealing in Disruption - OA policy in an African contextDealing in Disruption - OA policy in an African context
Dealing in Disruption - OA policy in an African context
 
The Changing Journal Landscape
The Changing Journal Landscape The Changing Journal Landscape
The Changing Journal Landscape
 
Scholarly Publishing in Africa - Namibia
Scholarly Publishing in Africa - NamibiaScholarly Publishing in Africa - Namibia
Scholarly Publishing in Africa - Namibia
 
Think
ThinkThink
Think
 
Codesria Conference on Electronic Publishing 2016
Codesria Conference on Electronic Publishing 2016 Codesria Conference on Electronic Publishing 2016
Codesria Conference on Electronic Publishing 2016
 
OA 2013 - A Broader Vision of Open Access for Development
OA 2013 - A Broader Vision of Open Access for Development OA 2013 - A Broader Vision of Open Access for Development
OA 2013 - A Broader Vision of Open Access for Development
 
Rom
RomRom
Rom
 
Open Access in 2012 – a developing country perspective
Open Access in 2012 – a developing country perspectiveOpen Access in 2012 – a developing country perspective
Open Access in 2012 – a developing country perspective
 
OA and the Decolonization of the university in Africa 2016
OA and the Decolonization of the university in Africa 2016 OA and the Decolonization of the university in Africa 2016
OA and the Decolonization of the university in Africa 2016
 
Open Access Week 2009 University of the Western Cape
Open Access Week 2009 University of the Western CapeOpen Access Week 2009 University of the Western Cape
Open Access Week 2009 University of the Western Cape
 
Mockito
MockitoMockito
Mockito
 
High powered messaging with RabbitMQ
High powered messaging with RabbitMQHigh powered messaging with RabbitMQ
High powered messaging with RabbitMQ
 

Similar a Intro to Node.js

Node.js introduction
Node.js introductionNode.js introduction
Node.js introduction
Prasoon Kumar
 

Similar a Intro to Node.js (20)

Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDD
 
Node js meetup
Node js meetupNode js meetup
Node js meetup
 
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
 
Node.js essentials
 Node.js essentials Node.js essentials
Node.js essentials
 
Nodejs
NodejsNodejs
Nodejs
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
Node js presentation
Node js presentationNode js presentation
Node js presentation
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.js
 
Advanced Node.JS Meetup
Advanced Node.JS MeetupAdvanced Node.JS Meetup
Advanced Node.JS Meetup
 
Node js
Node jsNode js
Node js
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
 
Node.js introduction
Node.js introductionNode.js introduction
Node.js introduction
 
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
Node JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppNode JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web App
 
Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6
 
02 Node introduction
02 Node introduction02 Node introduction
02 Node introduction
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
 
Introduction to node.js By Ahmed Assaf
Introduction to node.js  By Ahmed AssafIntroduction to node.js  By Ahmed Assaf
Introduction to node.js By Ahmed Assaf
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Intro to Node.js

  • 3. What Is It?  Server side javascript framework  Written using Google V8 Engine  Uses CommonJS module system  Has the latest and greatest Ecmascript5 features
  • 4. Non-Blocking I/O  The philosophy behind node.js is that system interactions should be non-blocking  Instead of this: var data = fs.readFile('foo.txt') console.log(data);  This: fs.readFile('foo.txt', function(data){ console.log(data); });
  • 5.  This whole operation is asynchronous... my application doesn't have to wait for the file to be read in  Using javascript to do this makes it easier to adopt given the existing knowledge of using callbacks and listeners on the client side
  • 6. Event Driven Architecture  This leads to a more event driven approach  Rather than returning something, calls should try to either − Call a callback passed in − Fire events that the caller listens for  Built in event system (EventEmitter) − emitter.emit('data-recvd', evt) − emitter.on('data-recvd', function(evt){ });
  • 8. Ecmascript 5 Features  Array Extras − Map, reduce, forEach, filter, every, some  JSON  Object Utilities  Object.getOwnPropertyNames  Object.create  Object.defineProperties  Object.getOwnPropertyDescriptor  Immutibility − Object.freeze, Object.seal
  • 9. Ecmascript 5 Features  Getters/setters  Function.prototype.bind − Allows you to create a new function with the argument(s) pre-set − Example function add(a,b){ return a+b; } var fivePlus = add.bind(5) console.log(fivePlus(2)); // prints 7
  • 10. Examples  Enough talking, let's see some examples − Some file and process interaction − A simple webserver − Reverse proxy − Websockets − AMQP to integrate with existing applications
  • 11. Getting Started  Runs on nix and cygwin (no windows support yet)  Install the latest stable from nodejs.org − Sorry, no installer. You'll need to build it yourself  Try the commandline repl out. If all is well, you're good to go!  Hack away
  • 12. npm  Ruby has gem, node has npm (node package manager)  This is a must have for node.js development − http://npmjs.org  Quick Install: − curl http://npmjs.org/install.sh | sh  Can also be used to budle up your application's dependencies
  • 13. Modules of Note  Some interesting modules to take note of and try out − Express – simple sintatra clone (a dime a dozen these days) − Vows – async BDD in javascript − Socket.IO – websockets made easy − Yui3 – adaption of YUI for node.js − SEVERAL NoSQL modules  Riak, redis, couchDB, mongoDB, tokyo cabinet, etc.
  • 14. Hosting Options  Heroku (closed beta)  Joyent (open beta)  Nodjitsu (launching soon)  DIY (EC2, your own server, etc)
  • 15. Cons  Evolving rapidly. − It's not uncommon to see tutorials from several months ago that no longer work  Not very cross platform (yet)  Lots of duplicate modules − Not that this is a bad thing, but for example there are TEN couchdb modules (because couchdb wrappers are simple to make)  No clustering support yet
  • 16. Clustering Support  No real support yet, but it's on the way! − EventEmitters backed by websockets − Another using Redis built-in publish/subscribe mechanisms − I've been hacking at EventEmitters backed by AMQP
  • 17. Users
  • 18. Join the Community!  irc.freenode.net #node.js  Google Groups node.js  File bugs/suggest features  Use and Contribute!