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
Nodejs - A-quick-tour-v3
Questions?




✎   @felixge / felix@debuggable.com

More Related Content

What's hot (20)

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
 
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
 
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
 

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
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
ActiveDOM
Felix Geisendörfer
 
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 Fogagnolo
Samuele 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_czesc2
GetResponsePL
 
การค้นหาข้อมูลสารสนเทศ 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
 
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
 
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 Fogagnolo
Samuele 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_czesc2
GetResponsePL
 
การค้นหาข้อมูลสารสนเทศ 2
การค้นหาข้อมูลสารสนเทศ 2การค้นหาข้อมูลสารสนเทศ 2
การค้นหาข้อมูลสารสนเทศ 2
Pathomporn Dulyarat
 
Enviar a todos
Enviar a todosEnviar a todos
Enviar a todos
V G
 
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
 

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

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
 
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
 
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
 
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
 
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
 
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
 

Nodejs - A-quick-tour-v3