Node.js is an asynchronous JavaScript runtime built on Chrome's V8 JavaScript engine. It uses an event-driven, non-blocking I/O model that makes it lightweight and efficient for data-intensive real-time applications. Key features include its event loop that handles asynchronous callbacks instead of threads, the EventEmitter for event handling, and the NPM package manager. Popular Node.js frameworks like Express make it easy to build web servers and APIs, and modules like node-canvas allow creating images. The Node.js community is very active on GitHub and Google Groups.
1 of 18
Downloaded 38 times
More Related Content
@techmeetup Edinburgh nodejs talk
1. ??
Tane Piper - @tanepiper
An Introduction To
http://nodejs.org
2. ??
What Is Node?
nodejs (node) is a set of bindings to the V8
javascript VM. They allow developers to script
programs using asynchronous I/O in javascript.
Focused on performance and memory useage
through an event loop ¨C not threads.
3. ??
Features of Node
ª« Node is similar to
ª« Ruby's Event Machine
ª« Python's Twisted
ª« Node takes the event model a bit further¡ªit
presents the event loop as a language
construct instead of as a library.
ª« Node simply enters the event loop after
executing the input script. Node exits the
event loop when there are no more
callbacks to perform
8. ??
A HTTP Server in 4 lines
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");
console.log('Server?running?at?http://127.0.0.1:1337/');
9. ??
EventEmitter ¨C The powerhouse
of node
This should look familiar to most of you:
jQuery('.foo').click(function()?{
var?foo?=?this.attr('rel');
});
10. ??
EventEmitter ¨C The powerhouse
of node
var?EventEmitter?=?require('events').EventEmitter;
var?emitter?=?new?EventEmitter;
emitter.on('name',?function(data){
????console.log(data?+?'?rocks');
});
emitter.emit('name',?'nodejs');
emitter.emit('name',?'techmeetup');
11. ??
EventEmitter ¨C A I/O Example
var?spawn?=?require('child_process').spawn,
????ls????=?spawn('ls',?['?lh',?'/usr']);
ls.stdout.on('data',?function?(data)?{
??console.log('stdout:?'?+?data);
});
ls.stderr.on('data',?function?(data)?{
??console.log('stderr:?'?+?data);
});
ls.on('exit',?function?(code)?{
??console.log('child?proc?exited?with?code?'?+?code);
});
12. ??
NPM ¨C Node Package Manager
https://github.com/isaacs/npm
Used to install and publish your node programs.
JSON package format that It manages
dependencies.
Integrates nicely with man pages
13. ??
ExpressJS ¨C Nodejs-powered
framework
npm install express
Robust routing
Redirection helpers
Dynamic view helpers
Application level view options
Content negotiation
Focus on high performance
View rendering and partials support
Environment based configuration
Session based flash notifications