Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Node.js Introduction
Search
Brandon Keepers
PRO
March 26, 2012
Programming
34
1.5k
Node.js Introduction
A brief introduction to Node.js given at the
Grand Rapids Web Development Group
.
Brandon Keepers
PRO
March 26, 2012
Tweet
Share
More Decks by Brandon Keepers
See All by Brandon Keepers
Automating Software Development
bkeepers
PRO
2
370
Building the GitHub workspace app
bkeepers
PRO
1
270
Contributing to Your Career
bkeepers
PRO
3
610
A Maturity Model for Embracing Open Source Software
bkeepers
PRO
3
810
Open Source Principles for Internal Engineering Teams
bkeepers
PRO
7
1.2k
Carbon, Automobiles, Bebop & Fashion
bkeepers
PRO
1
380
Tending Your Open Source Garden, v2
bkeepers
PRO
1
450
Tending Your Open Source Garden
bkeepers
PRO
2
850
The Loyal Renegade
bkeepers
PRO
3
720
Other Decks in Programming
See All in Programming
なぜ宣言的 UI は壊れにくいのか / Why declarative UI is less fragile
uenitty
29
13k
Product Management LT会_クアンド新家
shinshin
0
210
20240706_CDKConf
takuyay0ne
0
1.2k
Terraformテスト入門
msato
0
520
ドメイン駆動設計の実践
masuda220
PRO
17
5.1k
Modern Angular: Renovation for Your Applications
manfredsteyer
PRO
0
140
유연한 Composable 설계
l2hyunwoo
0
380
生成AIをkintoneに連携してみた
hideg
0
230
DMMプラットフォームにおけるTiDBの導入から運用まで
pospome
7
3k
TiDB Serverless ~理想のServerless DBを考える~
soso_15315
1
160
CSC307 Lecture 11
javiergs
PRO
0
240
Polarsの成長: v0.14からv1.0までの変遷と今後の展望
zerebom
1
350
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
219
8.8k
5 minutes of I Can Smell Your CMS
philhawksworth
200
19k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
36
9.1k
How To Stay Up To Date on Web Technology
chriscoyier
784
250k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
90
47k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
24
1.8k
Visualization
eitanlees
139
14k
Building an army of robots
kneath
301
42k
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
189
16k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
325
21k
Web Components: a chance to create the future
zenorocha
307
41k
Transcript
INTRODUCTION
Hi, I’m @bkeepers
None
nodejs.org 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.
server side JavaScript
$ node webserver.js var http = require('http'), server = http.createServer();
server.on('request', function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }); server.listen(1337, "127.0.0.1"); console.log('Server running at http://127.0.0.1:1337/'); webserver.js
None
event loop modules package management
non-blocking evented I/O
event driven
event driven Button
event driven Button
event driven Button $('button').on('click', function(event) { alert('Event Driven!') });
event driven server.on('request', function(req, res) { res.write(handleRequest(req)) });
non-blocking
None
// blocking var files = fs.readdirSync('/tmp') for(var i = 0;
i < files.length; i++) { var file = files[i]; fs.unlinkSync('/tmp/' + file); console.log('successfully deleted ' + file); }
// blocking var files = fs.readdirSync('/tmp') for(var i = 0;
i < files.length; i++) { var file = files[i]; fs.unlinkSync('/tmp/' + file); console.log('successfully deleted ' + file); } // non-blocking fs.readdir('/tmp', function(err, files) { for(var i = 0; i < files.length; i++) { var file = files[i]; fs.unlink('/tmp/' + file, function (err) { if (err) throw err; console.log('successfully deleted ' + file); }); } });
CommonJS modules
JavaScript Pollutes
JavaScript Pollutes string = "pollution";
None
var http = require('http');
hello.js module.exports = function() { return 'Hello World' };
$ node myapp.js myapp.js var hello = require('./hello.js'); console.log(hello());
package management
npmjs.org
$ npm install <package>
package.json
package.json $ npm install { "name": "myapp", "version": "0.0.1", "dependencies":
{ "socket.io": "0.8.7", "coffee-script": "1.2.0", "spine": "~1.0.5" } }
building the simplest chat app in the world demo
references
http://nodejs.org/api/
None
thanks! @bkeepers