Your SlideShare is downloading. ×
0
Node.js quick intro
Node.js
Platform for scalable network applications
servers and clients
Uses event driven, non-blocking I/O
epoll, kqueue, ...
Event driven platform
Non-blocking - not waiting for things to finish
Uses asynchronous platform-specific API’s
“Single-th...
Node.js architecture
Based on V8
JavaScript Virtual
Machine (engine)
+ standard library
Google Chrome uses
V8 too
Event loop illustration
// event loop
while (true) {
lock (queue) {
var tickEvents = copy(queue);
queue.empty();
}
for (va...
Callbacks
var fs = require(“fs”);
var cb = function(err, data){
if (err) throw err;
console.log(“File contents: ” + data);...
Http server app
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 't...
Node.js launching
$ echo ‘console.log(“hey there”)’ | node
$ node app.js
Workers event loop
That was quick Node.js introduction
Thanks
Upcoming SlideShare
Loading in...5
×

Node.js quick intro

508

Published on

Very basic Node.js introduction

Published in: Software, Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
508
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Node.js quick intro"

  1. 1. Node.js quick intro
  2. 2. Node.js Platform for scalable network applications servers and clients Uses event driven, non-blocking I/O epoll, kqueue, /dev/poll, or select process never blocks, no deadlocks internal event loop
  3. 3. Event driven platform Non-blocking - not waiting for things to finish Uses asynchronous platform-specific API’s “Single-threaded” - sequential task execution Runs synchronous API’s in threads
  4. 4. Node.js architecture Based on V8 JavaScript Virtual Machine (engine) + standard library Google Chrome uses V8 too
  5. 5. Event loop illustration // event loop while (true) { lock (queue) { var tickEvents = copy(queue); queue.empty(); } for (var i = 0; i < tickEvents.length; i++) { InvokeJSFunction(tickEvents[i]); } } // thread-safe event pushing lock (queue) { queue.push(event); } // io call fs.readFile(“pwd”, function(e, d){ console.log(“file data:”, d); });
  6. 6. Callbacks var fs = require(“fs”); var cb = function(err, data){ if (err) throw err; console.log(“File contents: ” + data); } fs.readFile(“pwd1”, cb); fs.readFile(“pwd2”, cb);
  7. 7. Http server app var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello Worldn'); }).listen(1337, "127.0.0.1");
  8. 8. Node.js launching $ echo ‘console.log(“hey there”)’ | node $ node app.js
  9. 9. Workers event loop
  10. 10. That was quick Node.js introduction Thanks
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×