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
선언형 UI에서의 상태관리
l2hyunwoo
0
140
命名をリントする
chiroruxx
1
380
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
190
N.E.X.T LEVEL
pluu
2
300
モバイルアプリにおける自動テストの導入戦略
ostk0069
0
110
プロダクトの品質に コミットする / Commit to Product Quality
pekepek
2
760
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
Refactor your code - refactor yourself
xosofox
1
260
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
第5回日本眼科AI学会総会_AIコンテスト_3位解法
neilsaw
0
170
たのしいparse.y
ydah
3
120
As an Engineers, let's build the CRM system via LINE Official Account 2.0
clonn
1
670
Featured
See All Featured
Optimizing for Happiness
mojombo
376
70k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.3k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
440
Raft: Consensus for Rubyists
vanstee
137
6.7k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
Navigating Team Friction
lara
183
15k
How GitHub (no longer) Works
holman
311
140k
Speed Design
sergeychernyshev
25
670
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
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