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
3
460
Building the GitHub workspace app
bkeepers
PRO
1
340
Contributing to Your Career
bkeepers
PRO
3
700
A Maturity Model for Embracing Open Source Software
bkeepers
PRO
3
900
Open Source Principles for Internal Engineering Teams
bkeepers
PRO
7
1.3k
Carbon, Automobiles, Bebop & Fashion
bkeepers
PRO
1
510
Tending Your Open Source Garden, v2
bkeepers
PRO
1
570
Tending Your Open Source Garden
bkeepers
PRO
2
950
The Loyal Renegade
bkeepers
PRO
3
840
Other Decks in Programming
See All in Programming
PromptyによるAI開発入門
ymd65536
1
320
生産性アップのためのAI個人活用
kunoyasu
0
450
snacks.nvim内のセットアップ不要なプラグインを紹介 / introduce_snacks_nvim
uhooi
0
220
イベントソーシングによってインピーダンスミスマッチから解放された話
tkawae
1
250
requirements with math
moony
0
470
CQRS+ES勉強会#1
rechellatek
0
330
もう一人で悩まない! 個の知見をチームの知見にする3つの習慣と工夫 / Into team knowledge.
honyanya
3
490
ローコードサービスの進化のためのモノレポ移行
taro28
1
240
RecSys2024 参加報告
unonao
1
160
RCPと宣言型ポリシーについてのお話し
kokitamura
2
110
AtCoder Heuristic First-step Vol.1 講義スライド(山登り法・焼きなまし法編)
takumi152
2
410
Devin , 正しい付き合い方と使い方 / Living and Working with Devin
yukinagae
1
430
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
91
5.9k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
30
4.7k
GitHub's CSS Performance
jonrohan
1030
460k
Faster Mobile Websites
deanohume
306
31k
Documentation Writing (for coders)
carmenintech
69
4.7k
YesSQL, Process and Tooling at Scale
rocio
172
14k
How to Think Like a Performance Engineer
csswizardry
22
1.4k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.7k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
470
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
1.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Speed Design
sergeychernyshev
28
840
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