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.6k
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
420
Building the GitHub workspace app
bkeepers
PRO
1
310
Contributing to Your Career
bkeepers
PRO
3
670
A Maturity Model for Embracing Open Source Software
bkeepers
PRO
3
870
Open Source Principles for Internal Engineering Teams
bkeepers
PRO
7
1.3k
Carbon, Automobiles, Bebop & Fashion
bkeepers
PRO
1
460
Tending Your Open Source Garden, v2
bkeepers
PRO
1
520
Tending Your Open Source Garden
bkeepers
PRO
2
920
The Loyal Renegade
bkeepers
PRO
3
790
Other Decks in Programming
See All in Programming
Zoneless Testing
rainerhahnekamp
0
120
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
260
42 best practices for Symfony, a decade later
tucksaun
1
180
testcontainers のススメ
sgash708
1
120
今からはじめるAndroidアプリ開発 2024 / DevFest 2024
star_zero
0
1k
return文におけるstd::moveについて
onihusube
1
650
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
610
Recoilを剥がしている話
kirik
5
6.6k
nekko cloudにおけるProxmox VE利用事例
irumaru
3
420
良いユニットテストを書こう
mototakatsu
4
1.6k
事業成長を爆速で進めてきたプロダクトエンジニアたちの成功談・失敗談
nealle
3
1.4k
Featured
See All Featured
4 Signs Your Business is Dying
shpigford
181
21k
Six Lessons from altMBA
skipperchong
27
3.5k
Building Applications with DynamoDB
mza
91
6.1k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Writing Fast Ruby
sferik
628
61k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
GraphQLとの向き合い方2022年版
quramy
44
13k
KATA
mclloyd
29
14k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Building an army of robots
kneath
302
44k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
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