SlideShare a Scribd company logo
node.js
A quick tour (V3)




                    07.10.2010
About

Contributor                              Co-founder




                 Felix Geisendörfer   formidable
node.js driver                        node.js file uploads
Audience?
JavaScript?
What is node?
Server side JavaScript

$ git clone 
git://github.com/ry/node.git
$ cd node
$ ./configure
$ make install
Server side JavaScript

$ cat test.js
console.log('Hello World');

$ node test.js
Hello World
Server side JavaScript

$ node
> console.log('Hello World');
Hello World
>
Ingredients
         libeio            libev




c-ares                      V8


             http_parser
Philosophy

• Just enough core-library to do I/O

• Non-blocking

• Close to the underlaying system calls
Benevolent Dictator For Life




          Ryan Dahl
Concurrency Model
Non-blocking I/O

var fs = require('fs');

fs.readFile('test.txt', function(err, data) {
  if (err) throw err;

  console.log('Read file: ', data);
});

console.log('Reading file ...');
Single Threaded
var a = [];
function f() {
  a.push(1);
  a.push(2);
}

setTimeout(f, 10);
setTimeout(f, 10);
API Overview
CommonJS Modules
$ cat hello.js
exports.world = function() {
   return 'Hello World';
};

$ cat main.js
var hello = require('./hello');
console.log(hello.world());

$ node main.js
Hello World
Child processes
$ cat child.js
var cmd = 'echo hello; sleep 1; echo world;',
    spawn = require('child_process').spawn,
    child = spawn('sh', ['-c', cmd]);

child.stdout.on('data', function(chunk) {
  console.log(chunk.toString());
});

$ node child.js
"hellon"
# 1 sec delay
"worldnn"
Http Server
$ cat http.js
var http = require('http');
http.createServer(function(req, res) {
  setTimeout(function() {
    res.writeHead(200);
    res.end('Thanks for waiting!');
  }, 1000);
}).listen(4000);

$ curl localhost:4000
# 1 sec delay
Thanks for waiting!
Tcp Server
$ cat tcp.js
var tcp = require('tcp');
tcp.createServer(function(socket) {
  socket.on('connect', function() {
    socket.write("Hi, How Are You?n> ");
  });
  socket.on('data', function(data) {
    socket.write(data);
  });
}).listen(4000);

$ nc localhost 4000
Hi, How Are You?
> Great!
Great!
DNS

$ cat dns.js
var dns = require('dns');
dns.resolve('nodejs.org', function(err, addresses) {
 console.log(addresses);
});

$ node dns.js
[ '8.12.44.238' ]
Watch File
$ cat watch.js
var fs = require('fs');
fs.watchFile(__filename, function() {
  console.log('You changed me!');
  process.exit(0);
});

$ node watch.js
# edit watch.js
You changed me!
And much more

• UDP            • Buffer

• Crypto         • Script

• Assert         • EcmaScript5
           ...
Suitable Applications

• Web frameworks

• Real time

• Crawlers
More Applications

• Process monitoring

• File uploading

• Streaming
Interesting projects
Package management
Web Frameworks

• Express.js (Sinatra clone)

• Fab.js (Mind-bending & awesome)
DOM

• jsdom

• node-htmlparser

• apricot
WebSockets


 Socket.IO
Protocol parsers

• node-formidable

• node-mysql
....
Limitations

• Weak SSL support

• Weak Windows support

• 1GB Heap limit on x64 (V8)
Hosting
Questions?




✎   @felixge / felix@debuggable.com
Questions?




✎   @felixge / felix@debuggable.com

More Related Content

What's hot

Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)
Felix Geisendörfer
 
Node.js in production
Node.js in productionNode.js in production
Node.js in production
Felix Geisendörfer
 
Node.js - A Quick Tour
Node.js - A Quick TourNode.js - A Quick Tour
Node.js - A Quick Tour
Felix Geisendörfer
 
How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)
Felix Geisendörfer
 
Deploying Plone and Volto, the Hard Way
Deploying Plone and Volto, the Hard WayDeploying Plone and Volto, the Hard Way
Deploying Plone and Volto, the Hard Way
Asko Soukka
 
Shell Tips & Tricks
Shell Tips & TricksShell Tips & Tricks
Shell Tips & Tricks
MongoDB
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
Tom Croucher
 
Move Over, Rsync
Move Over, RsyncMove Over, Rsync
Move Over, Rsync
All Things Open
 
MongoDB Shell Tips & Tricks
MongoDB Shell Tips & TricksMongoDB Shell Tips & Tricks
MongoDB Shell Tips & Tricks
MongoDB
 
Redis - Usability and Use Cases
Redis - Usability and Use CasesRedis - Usability and Use Cases
Redis - Usability and Use Cases
Fabrizio Farinacci
 
Building the Enterprise infrastructure with PostgreSQL as the basis for stori...
Building the Enterprise infrastructure with PostgreSQL as the basis for stori...Building the Enterprise infrastructure with PostgreSQL as the basis for stori...
Building the Enterprise infrastructure with PostgreSQL as the basis for stori...
PavelKonotopov
 
Running High Performance & Fault-tolerant Elasticsearch Clusters on Docker
Running High Performance & Fault-tolerant Elasticsearch Clusters on DockerRunning High Performance & Fault-tolerant Elasticsearch Clusters on Docker
Running High Performance & Fault-tolerant Elasticsearch Clusters on Docker
Sematext Group, Inc.
 
Introduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCatsIntroduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCats
Derek Anderson
 
MongoDB's New Aggregation framework
MongoDB's New Aggregation frameworkMongoDB's New Aggregation framework
MongoDB's New Aggregation framework
Chris Westin
 
Lua tech talk
Lua tech talkLua tech talk
Lua tech talk
Locaweb
 
Getting Started with MongoDB
Getting Started with MongoDBGetting Started with MongoDB
Getting Started with MongoDB
Michael Redlich
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redis
Dvir Volk
 
Redis and its many use cases
Redis and its many use casesRedis and its many use cases
Redis and its many use cases
Christian Joudrey
 
Declare your infrastructure: InfraKit, LinuxKit and Moby
Declare your infrastructure: InfraKit, LinuxKit and MobyDeclare your infrastructure: InfraKit, LinuxKit and Moby
Declare your infrastructure: InfraKit, LinuxKit and Moby
Moby Project
 
Introduction to redis - version 2
Introduction to redis - version 2Introduction to redis - version 2
Introduction to redis - version 2
Dvir Volk
 

What's hot (20)

Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)
 
Node.js in production
Node.js in productionNode.js in production
Node.js in production
 
Node.js - A Quick Tour
Node.js - A Quick TourNode.js - A Quick Tour
Node.js - A Quick Tour
 
How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)
 
Deploying Plone and Volto, the Hard Way
Deploying Plone and Volto, the Hard WayDeploying Plone and Volto, the Hard Way
Deploying Plone and Volto, the Hard Way
 
Shell Tips & Tricks
Shell Tips & TricksShell Tips & Tricks
Shell Tips & Tricks
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
 
Move Over, Rsync
Move Over, RsyncMove Over, Rsync
Move Over, Rsync
 
MongoDB Shell Tips & Tricks
MongoDB Shell Tips & TricksMongoDB Shell Tips & Tricks
MongoDB Shell Tips & Tricks
 
Redis - Usability and Use Cases
Redis - Usability and Use CasesRedis - Usability and Use Cases
Redis - Usability and Use Cases
 
Building the Enterprise infrastructure with PostgreSQL as the basis for stori...
Building the Enterprise infrastructure with PostgreSQL as the basis for stori...Building the Enterprise infrastructure with PostgreSQL as the basis for stori...
Building the Enterprise infrastructure with PostgreSQL as the basis for stori...
 
Running High Performance & Fault-tolerant Elasticsearch Clusters on Docker
Running High Performance & Fault-tolerant Elasticsearch Clusters on DockerRunning High Performance & Fault-tolerant Elasticsearch Clusters on Docker
Running High Performance & Fault-tolerant Elasticsearch Clusters on Docker
 
Introduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCatsIntroduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCats
 
MongoDB's New Aggregation framework
MongoDB's New Aggregation frameworkMongoDB's New Aggregation framework
MongoDB's New Aggregation framework
 
Lua tech talk
Lua tech talkLua tech talk
Lua tech talk
 
Getting Started with MongoDB
Getting Started with MongoDBGetting Started with MongoDB
Getting Started with MongoDB
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redis
 
Redis and its many use cases
Redis and its many use casesRedis and its many use cases
Redis and its many use cases
 
Declare your infrastructure: InfraKit, LinuxKit and Moby
Declare your infrastructure: InfraKit, LinuxKit and MobyDeclare your infrastructure: InfraKit, LinuxKit and Moby
Declare your infrastructure: InfraKit, LinuxKit and Moby
 
Introduction to redis - version 2
Introduction to redis - version 2Introduction to redis - version 2
Introduction to redis - version 2
 

Viewers also liked

B2B 8 questions for ceo's
B2B   8 questions for ceo'sB2B   8 questions for ceo's
B2B 8 questions for ceo's
Futurelab
 
Romanian Retail 2.0
Romanian Retail 2.0Romanian Retail 2.0
Romanian Retail 2.0
Futurelab
 
With jQuery & CakePHP to World Domination
With jQuery & CakePHP to World DominationWith jQuery & CakePHP to World Domination
With jQuery & CakePHP to World Domination
Felix Geisendörfer
 
Customer Centric Retail Innovation - Bucharest May 29, 2008
Customer Centric Retail Innovation - Bucharest May 29, 2008Customer Centric Retail Innovation - Bucharest May 29, 2008
Customer Centric Retail Innovation - Bucharest May 29, 2008
Futurelab
 
ActiveDOM
ActiveDOMActiveDOM
Storytelling and TV Advertising (No Story, No Glory)
Storytelling and TV Advertising (No Story, No Glory)Storytelling and TV Advertising (No Story, No Glory)
Storytelling and TV Advertising (No Story, No Glory)
Futurelab
 
Training ACTE - 18400 - Samuele Fogagnolo
Training ACTE - 18400 - Samuele FogagnoloTraining ACTE - 18400 - Samuele Fogagnolo
Training ACTE - 18400 - Samuele FogagnoloSamuele Fogagnolo
 
Виртуальная выставка "Любимых книг забытые страницы"
Виртуальная выставка "Любимых книг забытые страницы"Виртуальная выставка "Любимых книг забытые страницы"
Виртуальная выставка "Любимых книг забытые страницы"
salekail
 
Unemployment benefits the essentials draft october 11 2010
Unemployment benefits   the essentials draft october 11 2010Unemployment benefits   the essentials draft october 11 2010
Unemployment benefits the essentials draft october 11 2010
Charles Lenchner
 
Iab showcase dobre_praktyki_czesc2
Iab showcase dobre_praktyki_czesc2Iab showcase dobre_praktyki_czesc2
Iab showcase dobre_praktyki_czesc2GetResponsePL
 
การค้นหาข้อมูลสารสนเทศ 2
การค้นหาข้อมูลสารสนเทศ 2การค้นหาข้อมูลสารสนเทศ 2
การค้นหาข้อมูลสารสนเทศ 2
Pathomporn Dulyarat
 
Enviar a todos
Enviar a todosEnviar a todos
Enviar a todos
V G
 
Creating A Mentoring Culture
Creating A Mentoring CultureCreating A Mentoring Culture
Creating A Mentoring Culture
Stacey Hoffer Weckstein
 
Osmデータ品質チェック方法
Osmデータ品質チェック方法Osmデータ品質チェック方法
Osmデータ品質チェック方法Yoshi Sato
 
20150624●2015年末溫暖送愛心活動專案
20150624●2015年末溫暖送愛心活動專案20150624●2015年末溫暖送愛心活動專案
20150624●2015年末溫暖送愛心活動專案Mignon Tang
 
DLYohn Leadership Lessons
DLYohn Leadership LessonsDLYohn Leadership Lessons
DLYohn Leadership Lessons
Denise Yohn
 

Viewers also liked (16)

B2B 8 questions for ceo's
B2B   8 questions for ceo'sB2B   8 questions for ceo's
B2B 8 questions for ceo's
 
Romanian Retail 2.0
Romanian Retail 2.0Romanian Retail 2.0
Romanian Retail 2.0
 
With jQuery & CakePHP to World Domination
With jQuery & CakePHP to World DominationWith jQuery & CakePHP to World Domination
With jQuery & CakePHP to World Domination
 
Customer Centric Retail Innovation - Bucharest May 29, 2008
Customer Centric Retail Innovation - Bucharest May 29, 2008Customer Centric Retail Innovation - Bucharest May 29, 2008
Customer Centric Retail Innovation - Bucharest May 29, 2008
 
ActiveDOM
ActiveDOMActiveDOM
ActiveDOM
 
Storytelling and TV Advertising (No Story, No Glory)
Storytelling and TV Advertising (No Story, No Glory)Storytelling and TV Advertising (No Story, No Glory)
Storytelling and TV Advertising (No Story, No Glory)
 
Training ACTE - 18400 - Samuele Fogagnolo
Training ACTE - 18400 - Samuele FogagnoloTraining ACTE - 18400 - Samuele Fogagnolo
Training ACTE - 18400 - Samuele Fogagnolo
 
Виртуальная выставка "Любимых книг забытые страницы"
Виртуальная выставка "Любимых книг забытые страницы"Виртуальная выставка "Любимых книг забытые страницы"
Виртуальная выставка "Любимых книг забытые страницы"
 
Unemployment benefits the essentials draft october 11 2010
Unemployment benefits   the essentials draft october 11 2010Unemployment benefits   the essentials draft october 11 2010
Unemployment benefits the essentials draft october 11 2010
 
Iab showcase dobre_praktyki_czesc2
Iab showcase dobre_praktyki_czesc2Iab showcase dobre_praktyki_czesc2
Iab showcase dobre_praktyki_czesc2
 
การค้นหาข้อมูลสารสนเทศ 2
การค้นหาข้อมูลสารสนเทศ 2การค้นหาข้อมูลสารสนเทศ 2
การค้นหาข้อมูลสารสนเทศ 2
 
Enviar a todos
Enviar a todosEnviar a todos
Enviar a todos
 
Creating A Mentoring Culture
Creating A Mentoring CultureCreating A Mentoring Culture
Creating A Mentoring Culture
 
Osmデータ品質チェック方法
Osmデータ品質チェック方法Osmデータ品質チェック方法
Osmデータ品質チェック方法
 
20150624●2015年末溫暖送愛心活動專案
20150624●2015年末溫暖送愛心活動專案20150624●2015年末溫暖送愛心活動專案
20150624●2015年末溫暖送愛心活動專案
 
DLYohn Leadership Lessons
DLYohn Leadership LessonsDLYohn Leadership Lessons
DLYohn Leadership Lessons
 

Similar to Nodejs - A-quick-tour-v3

introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
orkaplan
 
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
soft-shake.ch
 
Node.js: The What, The How and The When
Node.js: The What, The How and The WhenNode.js: The What, The How and The When
Node.js: The What, The How and The When
FITC
 
Matthew Eernisse, NodeJs, .toster {webdev}
Matthew Eernisse, NodeJs, .toster {webdev}Matthew Eernisse, NodeJs, .toster {webdev}
Matthew Eernisse, NodeJs, .toster {webdev}
.toster
 
NodeJS
NodeJSNodeJS
NodeJS
.toster
 
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
David Padbury
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js Applications
Ohad Kravchick
 
Node.js introduction
Node.js introductionNode.js introduction
Node.js introduction
Prasoon Kumar
 
Express Presentation
Express PresentationExpress Presentation
Express Presentation
aaronheckmann
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
Apaichon Punopas
 
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
async_io
 
Node.js vs Play Framework
Node.js vs Play FrameworkNode.js vs Play Framework
Node.js vs Play Framework
Yevgeniy Brikman
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejs
Amit Thakkar
 
Let s Enjoy Node.js
Let s Enjoy Node.jsLet s Enjoy Node.js
Let s Enjoy Node.js
Fred Chien
 
Nodejs Intro Part One
Nodejs Intro Part OneNodejs Intro Part One
Nodejs Intro Part One
Budh Ram Gurung
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Richard Lee
 
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
Aarti Parikh
 
Server side scripting smack down - Node.js vs PHP
Server side scripting smack down - Node.js vs PHPServer side scripting smack down - Node.js vs PHP
Server side scripting smack down - Node.js vs PHP
Marc Gear
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)
Yevgeniy Brikman
 

Similar to Nodejs - A-quick-tour-v3 (20)

introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
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
 
Node.js: The What, The How and The When
Node.js: The What, The How and The WhenNode.js: The What, The How and The When
Node.js: The What, The How and The When
 
Matthew Eernisse, NodeJs, .toster {webdev}
Matthew Eernisse, NodeJs, .toster {webdev}Matthew Eernisse, NodeJs, .toster {webdev}
Matthew Eernisse, NodeJs, .toster {webdev}
 
NodeJS
NodeJSNodeJS
NodeJS
 
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
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js Applications
 
Node.js introduction
Node.js introductionNode.js introduction
Node.js introduction
 
Express Presentation
Express PresentationExpress Presentation
Express Presentation
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
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
 
Node.js vs Play Framework
Node.js vs Play FrameworkNode.js vs Play Framework
Node.js vs Play Framework
 
Java script at backend nodejs
Java script at backend   nodejsJava script at backend   nodejs
Java script at backend nodejs
 
Let s Enjoy Node.js
Let s Enjoy Node.jsLet s Enjoy Node.js
Let s Enjoy Node.js
 
Nodejs Intro Part One
Nodejs Intro Part OneNodejs Intro Part One
Nodejs Intro Part One
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
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
 
Server side scripting smack down - Node.js vs PHP
Server side scripting smack down - Node.js vs PHPServer side scripting smack down - Node.js vs PHP
Server side scripting smack down - Node.js vs PHP
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)
 

Nodejs - A-quick-tour-v3