Bridging
The GAP
I’m Darcy.
Filter Squadhttp://github.com/filtersquad
cat ./README
• A brief History of JavaScript
• {Ruby,Rails} + JS Love
• Building Cool Stuff with ExecJS
Most Importantly,
Becoming a Better Ruby
Developer With
JavaScript
A short History of JavaScript
Act 1
Created by Brendan Eich
in 1995 at Netscape
Prototype Based
Dynamic & Weak Typing
Functions are First Class
~1996 until ~2004
The Browser Wars &
The DHTML Years
~2004 until ~2008
AJAX and Web 2.0
~2008 to Now
HTML5 & The Return
to the Server Side
0.1.0 Released Late 2009
Server Side JS isn’t New.
1996: NetScape LiveWire
1997: Rhino created
1997: JScript via ASP
2000: JScript.NET
2005: Helma released
2007: AppJet Launched
2008: Aptana Jaxer hits 1.0
2009: Node.JS Released
JavaScript and I
Act 2
Mid 2008:
I started writing an IRC Bot
Bright Idea:
JavaScript Plugins
Client in Ruby,
Plugins in JavaScript
Early 2010:
I discovered CoffeeScript
“Simple, transparent CoffeeScript support
for Rails and Rack Apps”.
The Gap
Act 3
Ruby JavaScript
Ruby JavaScript
Ruby JavaScriptBridgingThe Gap
Client Side
Act 4
RJS
Red + RedShifthttps://github.com/jessesielaff/red/
RKellyhttp://bit.ly/9nLw4R
Unobtrusive RJS(Rails >= 3.0),
e.g. https://github.com/rails/jquery-ujs
CoffeeScript
Rails 3.1 Asset Pipeline
HandleBar / Mustache
Same template Code on Client & Server
Server Side
Act 5
gem install coffee-script
0.1.0 until 0.3.2
Ruby-based Compiler
Barista + BistroCar
Call Library via Node
Gem Version ~> 1.0
Uses the gem ‘node’
Gem Version <= 2.2, >= 2.0
Built in Engines Approach
Gem Version ~> 2.2
Uses ExecJS instead
Baristahttps://github.com/sutto/barista/
ExecJShttps://github.com/sstephenson/execjs
therubyracer
therubyrhino
johnson
mustang
Apple JavaScript Core (JSC)
Mozilla Spidermonkey
Microsoft Windows Script Host
Node.js
Uses first available RunTime
Uglifierhttps://github.com/lautis/uglifier
Rails 3.1 Asset Pipeline
Building Stuff with ExecJS
RedJShttps://github.com/cowboyd/redjs
“Rspecs for a Ruby interface to javascript.”
Embedding vs.
Just Running Code
More Traditional Approaches
Juggernaut 2https://github.com/maccman/juggernaut
Ruby / Other Languages
Redis PubSub
Node.JS Server
Browser
Ruby / Other Languages
Redis PubSub
Node.JS Server
Browser
Ruby / Other Languages
Redis PubSub
Node.JS Server
Browser
Ruby / Other Languages
Redis PubSub
Node.JS Server
Browser
See Also: ZeroMQ
Conclusion
Thanks!
Questions?