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
320
Building the GitHub workspace app
bkeepers
PRO
1
240
Contributing to Your Career
bkeepers
PRO
2
590
A Maturity Model for Embracing Open Source Software
bkeepers
PRO
3
780
Open Source Principles for Internal Engineering Teams
bkeepers
PRO
7
1.2k
Carbon, Automobiles, Bebop & Fashion
bkeepers
PRO
1
350
Tending Your Open Source Garden, v2
bkeepers
PRO
1
420
Tending Your Open Source Garden
bkeepers
PRO
2
810
The Loyal Renegade
bkeepers
PRO
3
660
Other Decks in Programming
See All in Programming
大規模UIKitベースアプリへのTCAの段階的導入/gradual-adoption-of-tca-in-a-large-scale-uikit-based-app
takehilo
2
220
R言語の環境構築と基礎 Tokyo.R 112
bob3bob3
0
290
Elm Form Validation
bkuhlmann
0
520
Let's learn code review
riofujimon
2
620
“Seeing Like a Programmer”—Resiliency, Limits, and Moral Hazards in Software Engineering (LambdaConf 2024)
chriskrycho
0
350
『Railsオワコン』と言われる時代に、なぜブルーモ証券はRailsを選ぶのか
free_world21
2
400
AppRouter Panel Talk
yosuke_furukawa
PRO
1
500
Productivity is Messing Around and Having Fun
hollycummins
1
110
GraphQLサーバの構成要素を整理する #ハッカー鮨 #tsukijigraphql / graphql server technology selection
izumin5210
4
920
Webアプリをできるだけコードを手書きしないで作ってみる
tomokusaba
2
190
Native Federation: The Future of Micro Frontends in Angular
manfredsteyer
PRO
0
140
Ruby on Fails - effective error handling with Rails conventions
talyssonoc
0
210
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
228
16k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
26
2.3k
Design by the Numbers
sachag
274
18k
Designing Experiences People Love
moore
136
23k
Agile that works and the tools we love
rasmusluckow
325
20k
The Cost Of JavaScript in 2023
addyosmani
21
3.9k
How To Stay Up To Date on Web Technology
chriscoyier
782
250k
VelocityConf: Rendering Performance Case Studies
addyosmani
321
23k
Teambox: Starting and Learning
jrom
128
8.4k
Designing with Data
zakiwarfel
96
4.8k
Reflections from 52 weeks, 52 projects
jeffersonlam
345
19k
RailsConf 2023
tenderlove
9
570
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