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
440
Building the GitHub workspace app
bkeepers
PRO
1
330
Contributing to Your Career
bkeepers
PRO
3
680
A Maturity Model for Embracing Open Source Software
bkeepers
PRO
3
890
Open Source Principles for Internal Engineering Teams
bkeepers
PRO
7
1.3k
Carbon, Automobiles, Bebop & Fashion
bkeepers
PRO
1
490
Tending Your Open Source Garden, v2
bkeepers
PRO
1
550
Tending Your Open Source Garden
bkeepers
PRO
2
940
The Loyal Renegade
bkeepers
PRO
3
820
Other Decks in Programming
See All in Programming
[JAWS-UG横浜 #80] うわっ…今年のServerless アップデート、少なすぎ…?
maroon1st
1
170
TokyoR116_BeginnersSession1_環境構築
kotatyamtema
0
110
社内フレームワークとその依存性解決 / in-house framework and its dependency management
vvakame
1
550
Formの複雑さに立ち向かう
bmthd
1
720
[JAWS-UG横浜 #79] re:Invent 2024 の DB アップデートは Multi-Region!
maroon1st
1
140
一休.com のログイン体験を支える技術 〜Web Components x Vue.js 活用事例と最適化について〜
atsumim
0
110
Honoとフロントエンドの 型安全性について
yodaka
4
250
第3回関東Kaggler会_AtCoderはKaggleの役に立つ
chettub
3
890
Flutter × Firebase Genkit で加速する生成 AI アプリ開発
coborinai
0
150
時計仕掛けのCompose
mkeeda
1
280
CI改善もDatadogとともに
taumu
0
110
Unity Android XR入門
sakutama_11
0
140
Featured
See All Featured
Optimizing for Happiness
mojombo
376
70k
Producing Creativity
orderedlist
PRO
343
39k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
4 Signs Your Business is Dying
shpigford
182
22k
Building Adaptive Systems
keathley
40
2.4k
The Language of Interfaces
destraynor
156
24k
The Cult of Friendly URLs
andyhume
78
6.2k
Facilitating Awesome Meetings
lara
51
6.2k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
Into the Great Unknown - MozCon
thekraken
35
1.6k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.4k
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