Your SlideShare is downloading. ×
Node.js quick intro
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Node.js quick intro

463
views

Published on

Very basic Node.js introduction

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
463
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
8
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Node.js quick intro
  • 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. 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. Node.js architecture Based on V8 JavaScript Virtual Machine (engine) + standard library Google Chrome uses V8 too
  • 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. 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. 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. Node.js launching $ echo ‘console.log(“hey there”)’ | node $ node app.js
  • 9. Workers event loop
  • 10. That was quick Node.js introduction Thanks