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
Rails with Node.js - a Reese's Moment
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Jerry Cheung
September 26, 2011
Programming
500
1
Share
Rails with Node.js - a Reese's Moment
Introduction to Node.js and how to use it alongside Rails.
Jerry Cheung
September 26, 2011
More Decks by Jerry Cheung
See All by Jerry Cheung
Let's Build Software!
jch
3
170
Evented Ruby vs. Node.js
jch
9
1.9k
Streaming APIs with Ruby
jch
5
660
Evented Ruby vs Node.js
jch
15
4k
Sproutcore Introduction @ LAHN
jch
1
180
Other Decks in Programming
See All in Programming
[PHPerKaigi 2026]PHPerKaigi2025の企画CodeGolfが最高すぎて社内で内製して半年運営して得た内製と運営の知見
ikezoemakoto
0
340
Laravel Nightwatchの裏側 - Laravel公式Observabilityツールを支える設計と実装
avosalmon
1
320
GoのDB アクセスにおける 「型安全」と「柔軟性」の両立 - Bob という選択肢
tak848
0
310
レガシーPHP転生 〜父がドメインエキスパートだったのでDDD+Claude Codeでチート開発します〜
panda_program
0
450
Radical Imagining - LIFT 2025-2027 Policy Agenda
lift1998
0
250
Don't Prompt Harder, Structure Better
kitasuke
0
310
Java 21/25 Virtual Threads 소개
debop
0
330
今からFlash開発できるわけないじゃん、ムリムリ! (※ムリじゃなかった!?)
arkw
0
180
L’IA au service des devs : Anatomie d'un assistant de Code Review
toham
0
210
AIエージェントで業務改善してみた
taku271
0
480
「効かない!」依存性注入(DI)を活用したAPI Platformのエラーハンドリング奮闘記
mkmk884
0
310
PHPで TLSのプロトコルを実装してみるをもう一度しゃべりたい
higaki_program
0
180
Featured
See All Featured
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
260
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
250
Evolving SEO for Evolving Search Engines
ryanjones
0
170
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
The browser strikes back
jonoalderson
0
900
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.5k
So, you think you're a good person
axbom
PRO
2
2k
エンジニアに許された特別な時間の終わり
watany
106
240k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
RailsConf 2023
tenderlove
30
1.4k
Transcript
Rails with Node.js a Reese’s Moment Monday, September 26, 11
Me Monday, September 26, 11
In a Nutshell Monday, September 26, 11
In a Nutshell • Framework for building network apps Monday,
September 26, 11
In a Nutshell • Framework for building network apps •
First class evented I/O Monday, September 26, 11
In a Nutshell • Framework for building network apps •
First class evented I/O • Built on top of V8 Monday, September 26, 11
What it ain’t Monday, September 26, 11
What it ain’t • NOT a browser side Javascript library
Monday, September 26, 11
What it ain’t • NOT a browser side Javascript library
• NOT a full fledged webapp framework Monday, September 26, 11
A Simple Example Monday, September 26, 11
A Simple Example (1..3).each do |i| contents = File.read('presentation.key') puts
"#{i}. Finished reading file" puts "#{i}. doing something important..." end Monday, September 26, 11
A Simple Example 1. Finished reading file 1. doing something
important... 2. Finished reading file 2. doing something important... 3. Finished reading file 3. doing something important... Monday, September 26, 11
A Simple Example var fs = require('fs'); for (var i=1;
i<=3; i++) { fs.readFile('presentation.key', function(err, data) { console.log(i + ". Finished reading file"); }); console.log(i + ". doing something important..."); } Monday, September 26, 11
A Simple Example var fs = require('fs'); for (var i=1;
i<=3; i++) { fs.readFile('presentation.key', function(err, data) { console.log(i + ". Finished reading file"); }); console.log(i + ". doing something important..."); } Monday, September 26, 11
A Simple Example 1. doing something important... 2. doing something
important... 3. doing something important... 4. Finished reading file 4. Finished reading file 4. Finished reading file Monday, September 26, 11
Trust Callbacks Monday, September 26, 11
Trust Callbacks • Async programming is trickier Monday, September 26,
11
Trust Callbacks • Async programming is trickier • ...But it
doesn’t block your other code Monday, September 26, 11
Go to Jail “Node jails you into this evented- style
programming. You can’t do things in a blocking way, you can’t write slow programs.” - Ryan Dahl Monday, September 26, 11
Some Real Examples Monday, September 26, 11
Some Real Examples • Real-time dashboards and analytics Monday, September
26, 11
Some Real Examples • Real-time dashboards and analytics • Push
notifications Monday, September 26, 11
Some Real Examples • Real-time dashboards and analytics • Push
notifications • Fast file uploads Monday, September 26, 11
Dashboards + Analytics https://github.com/etsy/statsd Monday, September 26, 11
Dashboards + Analytics http://hummingbirdstats.com/ Monday, September 26, 11
Push Notifications https://github.com/mape/node-wargames Monday, September 26, 11
File Uploaders Monday, September 26, 11
File Uploaders • Slow to parse the encoded upload body
Monday, September 26, 11
File Uploaders • Slow to parse the encoded upload body
• Post-processing & background jobs Monday, September 26, 11
File Uploaders require 'sinatra' # curl -F "
[email protected]
" http://localhost:4567/upload post
'/upload' do # already written to params[:data][:tempfile] "" end Monday, September 26, 11
Upload Benchmarks MRI Ruby 1.8.7 and 1.9.2 with Sinatra 1.2.1
Node 0.5.0 2.66 GHz i7 2000 iterations on a 295 byte file Monday, September 26, 11
Upload Benchmarks MRI Ruby 1.8.7 and 1.9.2 with Sinatra 1.2.1
Node 0.5.0 2.66 GHz i7 2000 iterations on a 295 byte file Monday, September 26, 11
Upload Benchmarks MRI Ruby 1.8.7 and 1.9.2 with Sinatra 1.2.1
Node 0.5.0 2.66 GHz i7 2000 iterations on a 295 byte file Ruby 67 minutes 3.5 seconds Node 23.9 seconds Monday, September 26, 11
Upload Benchmarks MRI Ruby 1.8.7 and 1.9.2 with Sinatra 1.2.1
Node 0.5.0 2.66 GHz i7 2000 iterations on a 295 byte file Ruby 67 minutes 3.5 seconds Node 23.9 seconds Monday, September 26, 11
Upload Benchmarks MRI Ruby 1.8.7 and 1.9.2 with Sinatra 1.2.1
Node 0.5.0 2.66 GHz i7 2000 iterations on a 295 byte file Ruby 67 minutes 3.5 seconds Node 23.9 seconds Monday, September 26, 11
Upload Benchmarks MRI Ruby 1.8.7 and 1.9.2 with Sinatra 1.2.1
Node 0.5.0 2.66 GHz i7 2000 iterations on a 295 byte file Ruby 67 minutes 3.5 seconds Node 23.9 seconds Monday, September 26, 11
No Silver Bullet Monday, September 26, 11
No Silver Bullet • Not a replacement for Ruby Monday,
September 26, 11
No Silver Bullet • Not a replacement for Ruby •
Use where it makes sense Monday, September 26, 11
No Silver Bullet • Not a replacement for Ruby •
Use where it makes sense • Doesn’t guarantee scalability Monday, September 26, 11
Wrapup Monday, September 26, 11
Wrapup • Server side Javascript rules! Monday, September 26, 11
Wrapup • Server side Javascript rules! • Event driven style
of programming Monday, September 26, 11
Wrapup • Server side Javascript rules! • Event driven style
of programming • Good for specific problems Monday, September 26, 11
Thanks! Questions?
[email protected]
@whatcodecraves http://whatcodecraves.com Monday, September 26, 11