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
400
Building the GitHub workspace app
bkeepers
PRO
1
300
Contributing to Your Career
bkeepers
PRO
3
650
A Maturity Model for Embracing Open Source Software
bkeepers
PRO
3
850
Open Source Principles for Internal Engineering Teams
bkeepers
PRO
7
1.3k
Carbon, Automobiles, Bebop & Fashion
bkeepers
PRO
1
430
Tending Your Open Source Garden, v2
bkeepers
PRO
1
490
Tending Your Open Source Garden
bkeepers
PRO
2
880
The Loyal Renegade
bkeepers
PRO
3
760
Other Decks in Programming
See All in Programming
Jakarta EE as Seen Trough the Lens of the ASF
ivargrimstad
0
860
もう実家に手頃な情シス娘は不要!Bedrockでもう一人の娘を作る
komakichi
2
150
tc39 x jsconf.jp Panel Discussion 2024
yosuke_furukawa
PRO
0
110
現場から考えるソフトウェアエンジニアリングの価値と実験
nomuson
1
140
知られざるNaNの世界
hole
3
1.1k
Vue3の一歩踏み込んだパフォーマンスチューニング2024
hal_spidernight
3
2k
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
1.2k
Micro Frontends for Java Microservices - dev2next 2024
mraible
PRO
0
230
2万ページのSSG運用における工夫と注意点 / Vue Fes Japan 2024
chinen
3
850
Kubernetes上でOracle_Databaseの運用を楽にするOraOperatorの紹介
nnaka2992
0
170
個人開発で使ってるやつを紹介する回
yohfee
1
730
20241004 モノタロウ式~ドメインモデリングとリアーキテクチャ
monotaro
PRO
2
680
Featured
See All Featured
How GitHub (no longer) Works
holman
311
140k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
228
52k
Building an army of robots
kneath
302
42k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
7.6k
What's in a price? How to price your products and services
michaelherold
243
11k
GraphQLとの向き合い方2022年版
quramy
43
13k
GraphQLの誤解/rethinking-graphql
sonatard
66
9.9k
Build The Right Thing And Hit Your Dates
maggiecrowley
32
2.3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
How to Think Like a Performance Engineer
csswizardry
18
1k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
231
17k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
9
630
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