Created by @xjodoin
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
Source: Ryan Dahl’s 2008.11.08 node.js presentation
No function should perform i/o directly.
To receive info from disk, network, or another process there must be a callback
var http = require('http'); var fs = require('fs'); var server = http.createServer(function (req, res) { fs.readFile(__dirname + '/data.txt', function (err, data) { res.end(data); }); }); server.listen(8000);
Stream everything. never force the buffering of data
var http = require('http'); var fs = require('fs'); var server = http.createServer(function (req, res) { var stream = fs.createReadStream(__dirname + '/data.txt'); stream.pipe(res); }); server.listen(8000);
single thread simplifies concurrency
Javascript client/server
Total Packages: 55 720