Slide 1

Slide 1 text

Bridging The GAP

Slide 2

Slide 2 text

I’m Darcy.

Slide 3

Slide 3 text

@sutto github.com/Sutto [email protected]

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Filter Squad http://github.com/filtersquad

Slide 6

Slide 6 text

http://github.com/youthtree

Slide 7

Slide 7 text

cat ./README •A brief History of JavaScript •Server & Client Side Tools

Slide 8

Slide 8 text

Most Importantly, Becoming a Better Ruby Developer Using JavaScript

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Ruby JavaScript

Slide 11

Slide 11 text

Ruby JavaScript

Slide 12

Slide 12 text

Ruby JavaScript Bridging The Gap

Slide 13

Slide 13 text

A Brief History of JavaScript Act 1

Slide 14

Slide 14 text

Prototype Based Dynamic & Weak Typing Functions are First Class

Slide 15

Slide 15 text

The Three Phases of JavaScript Development

Slide 16

Slide 16 text

~1996 until ~2004 The Browser Wars & The DHTML Years

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

~2004 until ~2008 AJAX and Web 2.0

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

~2008 to Now HTML5 & The Return to the Server Side

Slide 21

Slide 21 text

0.1.0 Released Late 2009

Slide 22

Slide 22 text

Server Side JS isn’t New.

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

1996: NetScape LiveWire 1997: Rhino created 1997: JScript via ASP 2000: JScript.NET

Slide 25

Slide 25 text

2005: Helma released 2007: AppJet Launched 2008: Aptana Jaxer hits 1.0 2009: Node.JS Released

Slide 26

Slide 26 text

JavaScript and I Act 2

Slide 27

Slide 27 text

Mid 2008: I started writing an IRC Bot

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

Bright Idea: JavaScript Plugins

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

Client in Ruby, Plugins in JavaScript

Slide 32

Slide 32 text

Early 2010: I discovered CoffeeScript

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

“Simple, transparent CoffeeScript support for Rails and Rack Apps”.

Slide 37

Slide 37 text

Client Side Act 3

Slide 38

Slide 38 text

RJS

Slide 39

Slide 39 text

render :update do |page| # Update the list of users via JavaScript page.replace_html 'user_list', :partial => 'user', :collection => @users # Now, highlight said list. page.visual_effect :highlight, 'user_list' end

Slide 40

Slide 40 text

Red + RedShift https://github.com/jessesielaff/red/

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

HotRuby http://hotruby.yukoba.jp/

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

RKelly http://bit.ly/9nLw4R

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

Unobtrusive RJS (Rails >= 3.0), e.g. https://github.com/rails/jquery-ujs

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

CoffeeScript

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

http://lesscss.org/

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

Rails 3.1 Asset Pipeline

Slide 53

Slide 53 text

Shared Templating

Slide 54

Slide 54 text

The Mustache Approach

Slide 55

Slide 55 text

http://mustache.github.com/ {

Slide 56

Slide 56 text

Same base Spec, Different Renderers.

Slide 57

Slide 57 text

Logic Less Template == Programming Language Inspecific

Slide 58

Slide 58 text

The Handlebars Approach

Slide 59

Slide 59 text

http://www.handlebarsjs.com/

Slide 60

Slide 60 text

HandleBars >= Mustache

Slide 61

Slide 61 text

Rails support via Handlebar-Rails http://bit.ly/e7FfGg

Slide 62

Slide 62 text

Same Handlebar.JS, Running Server + Client.

Slide 63

Slide 63 text

Server Side Act 4

Slide 64

Slide 64 text

gem install coffee-script

Slide 65

Slide 65 text

0.1.0 until 0.3.2 Ruby-based Compiler

Slide 66

Slide 66 text

Barista + BistroCar Call Library via Node

Slide 67

Slide 67 text

Gem Version ~> 1.0 Uses the gem ‘node’

Slide 68

Slide 68 text

Gem Version <= 2.2, >= 2.0 Built in Engines Approach

Slide 69

Slide 69 text

Gem Version ~> 2.2 Uses ExecJS instead

Slide 70

Slide 70 text

Barista https://github.com/sutto/barista/

Slide 71

Slide 71 text

ExecJS https://github.com/sstephenson/execjs

Slide 72

Slide 72 text

therubyracer therubyrhino johnson mustang

Slide 73

Slide 73 text

Apple JavaScript Core (JSC) Mozilla Spidermonkey Microsoft Windows Script Host Node.js

Slide 74

Slide 74 text

Uses first available RunTime

Slide 75

Slide 75 text

Uglifier https://github.com/lautis/uglifier

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

Rails 3.1 Asset Pipeline

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

Building Stuff with ExecJS

Slide 80

Slide 80 text

require 'execjs' p ExecJS.eval(<<-END) ["Hello", "World"].join(" ") END # => "Hello World"

Slide 81

Slide 81 text

var Welcome = { hello: function(who) { return "Hello " + who; } };

Slide 82

Slide 82 text

script = File.read('welcome.js') ctx = ExecJS.compile(script) p ctx.call('Welcome.hello', "World") # => "Hello World"

Slide 83

Slide 83 text

RedJS https://github.com/cowboyd/redjs

Slide 84

Slide 84 text

“Rspecs for a Ruby interface to javascript.”

Slide 85

Slide 85 text

embedded Runtimes vs. Way to invoke Runtime

Slide 86

Slide 86 text

it "can directly embed ruby values into javascript" do @cxt["bar"] = 9 @cxt['foo'] = "bar" @cxt['num'] = 3.14 @cxt['trU'] = true @cxt['falls'] = false @cxt.eval("bar + 10").should be(19) @cxt.eval('foo').should == "bar" @cxt.eval('num').should == 3.14 @cxt.eval('trU').should be(true) @cxt.eval('falls').should be(false) end

Slide 87

Slide 87 text

Other Approaches

Slide 88

Slide 88 text

Juggernaut 2 https://github.com/maccman/juggernaut

Slide 89

Slide 89 text

No content

Slide 90

Slide 90 text

Ruby / Other Languages Redis PubSub Node.JS Server Browser

Slide 91

Slide 91 text

Ruby / Other Languages Redis PubSub Node.JS Server Browser

Slide 92

Slide 92 text

Ruby / Other Languages Redis PubSub Node.JS Server Browser

Slide 93

Slide 93 text

Ruby / Other Languages Redis PubSub Node.JS Server Browser

Slide 94

Slide 94 text

See Also: ZeroMQ

Slide 95

Slide 95 text

Conclusion

Slide 96

Slide 96 text

Questions? http://www.flickr.com/photos/9557815@N05/3151304981/in/photostream/ - Opening Image http://www.colourlovers.com/palette/1836045/Reefcare - Colour Pallete http://www.flickr.com/photos/ericparker/5371174711/ - Bad Ass Latte Art http://www.flickr.com/photos/wili/3361117222/ - Adorable Seal Baby.