SlideShare a Scribd company logo
1 of 18
Download to read offline
  
Tane Piper - @tanepiper
An Introduction To
http://nodejs.org
  
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 – not threads.
  
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
  
Synchronous vs Asyncronous
$query="SELECT * FROM contacts";
$result=mysql_query($query);
­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
File file = new File("C:MyFile.txt");
fis = new FileInputStream(file);
fis.close();
  
What is the software doing?
  
x
http://www.flickr.com/photos/nationaalarchief/3675431410/
What is the software doing?
 It's Waiting –
Wasting cycles
  
Synchronous vs Asyncronous
db.query(”SELECT * FROM contacts”, function(err, rows) {
rows.forEach(function(row) {
console.log(row);
});
});
­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
fs.readFile('techmeetup.txt', function(data) {
console.log(data);
});
doSomethingElseWhileNotWaiting();
  
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/');
  
EventEmitter – The powerhouse
of node
This should look familiar to most of you:
jQuery('.foo').click(function() {
var foo = this.attr('rel');
});
  
EventEmitter – 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');
  
EventEmitter – 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);
});
  
NPM – 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
  
ExpressJS – 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
  
ExpressJS - Example
Var express = require('express');
var app = express.createServer();
app.get('/', function(req, res, next){
    res.send('Hello World');
});
app.post('/:name', function(req, res, next) {
var name = req.params.name;
   If (!name) {
     next(new Error('No name passed');
   } else {
     res.send(['Hello', name].join(' '));
   }
});
app.listen(3000);
  
Something new: node-canvas
var Canvas = require('canvas')
  , canvas = new Canvas(200,200)
  , ctx = canvas.getContext('2d');
var fs = require('fs')
  , out = fs.createWriteStream(__dirname + '/text.png')
  , stream = canvas.createPNGStream();
ctx.font = '30px Droid Sans';
ctx.rotate(.1);
ctx.fillText("Yay Techmeet Edinburgh!", 50, 100);
stream.on('data', function(chunk){
  out.write(chunk);
});
stream.on('end', function(){
  console.log('saved png');
});
  
Something new: node-canvas
  
nodejs Community
Google Groups:
nodejs – General Community
nodejs-dev – Low level development
https://github.com/ry/node/wiki/modules
  
Thank You
Any Questions?

More Related Content

What's hot

rOCCI – Providing Interoperability through OCCI 1.1 Support for OpenNebula
rOCCI – Providing Interoperability through OCCI 1.1 Support for OpenNebularOCCI – Providing Interoperability through OCCI 1.1 Support for OpenNebula
rOCCI – Providing Interoperability through OCCI 1.1 Support for OpenNebula
NETWAYS
 

What's hot (20)

rOCCI – Providing Interoperability through OCCI 1.1 Support for OpenNebula
rOCCI – Providing Interoperability through OCCI 1.1 Support for OpenNebularOCCI – Providing Interoperability through OCCI 1.1 Support for OpenNebula
rOCCI – Providing Interoperability through OCCI 1.1 Support for OpenNebula
 
Docker & azure
Docker & azureDocker & azure
Docker & azure
 
Cloud Foundry Logging and Metrics
Cloud Foundry Logging and MetricsCloud Foundry Logging and Metrics
Cloud Foundry Logging and Metrics
 
Free the Functions with Fn project!
Free the Functions with Fn project!Free the Functions with Fn project!
Free the Functions with Fn project!
 
Are you using an opensource library? There's a good chance you are vulnerable...
Are you using an opensource library? There's a good chance you are vulnerable...Are you using an opensource library? There's a good chance you are vulnerable...
Are you using an opensource library? There's a good chance you are vulnerable...
 
容器與IoT端點應用
容器與IoT端點應用容器與IoT端點應用
容器與IoT端點應用
 
C++からWebRTC (DataChannel)を利用する
C++からWebRTC (DataChannel)を利用するC++からWebRTC (DataChannel)を利用する
C++からWebRTC (DataChannel)を利用する
 
Angular v2 et plus : le futur du développement d'applications en entreprise
Angular v2 et plus : le futur du développement d'applications en entrepriseAngular v2 et plus : le futur du développement d'applications en entreprise
Angular v2 et plus : le futur du développement d'applications en entreprise
 
Production ready Vert.x
Production ready Vert.xProduction ready Vert.x
Production ready Vert.x
 
Lib uv node.js
Lib uv node.js Lib uv node.js
Lib uv node.js
 
Overview and Opentracing in theory by Gianluca Arbezzano
Overview and Opentracing in theory by Gianluca ArbezzanoOverview and Opentracing in theory by Gianluca Arbezzano
Overview and Opentracing in theory by Gianluca Arbezzano
 
Cloud Native Practice
Cloud Native PracticeCloud Native Practice
Cloud Native Practice
 
"fireap" - fast task runner on consul
"fireap" - fast task runner on consul"fireap" - fast task runner on consul
"fireap" - fast task runner on consul
 
Are you using an opensource library? There's a good chance you are vulnerable...
Are you using an opensource library? There's a good chance you are vulnerable...Are you using an opensource library? There's a good chance you are vulnerable...
Are you using an opensource library? There's a good chance you are vulnerable...
 
[UDS] Cloud Computing "pour les nuls" (Exemple avec LinShare)
[UDS] Cloud Computing "pour les nuls" (Exemple avec LinShare)[UDS] Cloud Computing "pour les nuls" (Exemple avec LinShare)
[UDS] Cloud Computing "pour les nuls" (Exemple avec LinShare)
 
Solid NodeJS with TypeScript, Jest & NestJS
Solid NodeJS with TypeScript, Jest & NestJSSolid NodeJS with TypeScript, Jest & NestJS
Solid NodeJS with TypeScript, Jest & NestJS
 
Welcome talk unleashing the future of open-source enterprise cloud computing
Welcome talk   unleashing the future of open-source enterprise cloud computingWelcome talk   unleashing the future of open-source enterprise cloud computing
Welcome talk unleashing the future of open-source enterprise cloud computing
 
Node.js Presentation
Node.js PresentationNode.js Presentation
Node.js Presentation
 
Paris Container Day 2016 : Cloud de conteneurs, conteneurs dans le cloud, str...
Paris Container Day 2016 : Cloud de conteneurs, conteneurs dans le cloud, str...Paris Container Day 2016 : Cloud de conteneurs, conteneurs dans le cloud, str...
Paris Container Day 2016 : Cloud de conteneurs, conteneurs dans le cloud, str...
 
Fluent Bit
Fluent BitFluent Bit
Fluent Bit
 

Similar to @techmeetup Edinburgh nodejs talk

NodeJS_Presentation
NodeJS_PresentationNodeJS_Presentation
NodeJS_Presentation
Arpita Patel
 
Node.js introduction
Node.js introductionNode.js introduction
Node.js introduction
Prasoon Kumar
 

Similar to @techmeetup Edinburgh nodejs talk (20)

Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
 
Nodejs
NodejsNodejs
Nodejs
 
Nodejs
NodejsNodejs
Nodejs
 
Proposal
ProposalProposal
Proposal
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Node js internal
Node js internalNode js internal
Node js internal
 
02 Node introduction
02 Node introduction02 Node introduction
02 Node introduction
 
Introduction to node.js By Ahmed Assaf
Introduction to node.js  By Ahmed AssafIntroduction to node.js  By Ahmed Assaf
Introduction to node.js By Ahmed Assaf
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
 
Appenginejs (old presentation)
Appenginejs (old presentation)Appenginejs (old presentation)
Appenginejs (old presentation)
 
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
 
Node js
Node jsNode js
Node js
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
 
Vert.x keynote for EclipseCon 2013
Vert.x keynote for EclipseCon 2013Vert.x keynote for EclipseCon 2013
Vert.x keynote for EclipseCon 2013
 
NodeJS_Presentation
NodeJS_PresentationNodeJS_Presentation
NodeJS_Presentation
 
Node Session - 1
Node Session - 1Node Session - 1
Node Session - 1
 
Node.js introduction
Node.js introductionNode.js introduction
Node.js introduction
 
Beginners Node.js
Beginners Node.jsBeginners Node.js
Beginners Node.js
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginners
 
Nodejs Native Add-Ons from zero to hero
Nodejs Native Add-Ons from zero to heroNodejs Native Add-Ons from zero to hero
Nodejs Native Add-Ons from zero to hero
 

Recently uploaded

Recently uploaded (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

@techmeetup Edinburgh nodejs talk