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
380
Building the GitHub workspace app
bkeepers
PRO
1
280
Contributing to Your Career
bkeepers
PRO
3
630
A Maturity Model for Embracing Open Source Software
bkeepers
PRO
3
830
Open Source Principles for Internal Engineering Teams
bkeepers
PRO
7
1.3k
Carbon, Automobiles, Bebop & Fashion
bkeepers
PRO
1
410
Tending Your Open Source Garden, v2
bkeepers
PRO
1
470
Tending Your Open Source Garden
bkeepers
PRO
2
860
The Loyal Renegade
bkeepers
PRO
3
740
Other Decks in Programming
See All in Programming
Rubyとクリエイティブコーディングの輪の広がり / The Growing Circle of Ruby and Creative Coding
chobishiba
1
220
仮想ファイルシステムを導入して開発環境のストレージ課題を解消する
segadevtech
2
390
Mergeable Libraryで 高速なアプリ起動を実現しよう!
giginet
PRO
1
1.8k
詳解UIWindow
natmark
3
2k
LR で JSON パーサーを作る / Coding LR JSON Parser
junk0612
2
170
2024 컴포즈 정원사
jisungbin
0
140
The Future of Frontend i18n : Intl.MessageFormat
sajikix
1
2.4k
LangChainでWebサイトの内容取得やGitHubソースコード取得
shukob
0
120
僕が思い描くTypeScriptの未来を勝手に先取りする
yukukotani
3
590
Regular Expressions, REXML, Automata Learning
makenowjust
0
180
健康第一!MetricKitで始めるアプリの健康診断 / App Health Checkups Starting with MetricKit
nekowen
4
790
楽しく簡単に!QRコードの読み取り機能を実装しよう
penguinsan_pg
1
190
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
30
6.2k
Music & Morning Musume
bryan
46
6k
Clear Off the Table
cherdarchuk
90
320k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
42
2k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
225
22k
Building Better People: How to give real-time feedback that sticks.
wjessup
359
18k
Building a Scalable Design System with Sketch
lauravandoore
458
32k
From Idea to $5000 a Month in 5 Months
shpigford
378
46k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
GraphQLの誤解/rethinking-graphql
sonatard
65
9.7k
Optimising Largest Contentful Paint
csswizardry
28
2.7k
Teambox: Starting and Learning
jrom
131
8.7k
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