Node.js quick intro
Upcoming SlideShare
Loading in...5
×
 

Node.js quick intro

on

  • 430 views

Very basic Node.js introduction

Very basic Node.js introduction

Statistics

Views

Total Views
430
Slideshare-icon Views on SlideShare
430
Embed Views
0

Actions

Likes
1
Downloads
5
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Node.js quick intro Node.js quick intro Presentation Transcript

    • Node.js quick intro
    • 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
    • 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
    • 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 (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); });
    • 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);
    • 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");
    • Node.js launching $ echo ‘console.log(“hey there”)’ | node $ node app.js
    • Workers event loop
    • That was quick Node.js introduction Thanks