Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

@brodock blog.gabrielmazetto.eti.br Gabriel Mazetto

Slide 3

Slide 3 text

There is a Ruby in your Browser

Slide 4

Slide 4 text

CREATE, COLLABORATE AND DEPLOY FROM IDEA TO PRODUCTION

Slide 5

Slide 5 text

We are going to talk a lot about languages today...

Slide 6

Slide 6 text

But first... Let's go back in time...

Slide 7

Slide 7 text

1980 - 1988

Slide 8

Slide 8 text

Hypertext Real-time RPC Computer Networking CERN, John Poole's ICS

Slide 9

Slide 9 text

Tim Berners-Lee

Slide 10

Slide 10 text

March, 1989

Slide 11

Slide 11 text

Hypertext + TCP + DNS

Slide 12

Slide 12 text

World Wide Web

Slide 13

Slide 13 text

Dec, 1990

Slide 14

Slide 14 text

WorldWideWeb First 'navigator'

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

1991-1993

Slide 17

Slide 17 text

Spreading the web Outside europe

Slide 18

Slide 18 text

1993

Slide 19

Slide 19 text

NCSA Mosaic 0.5

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

CERN Releases WorldWideWeb source code

Slide 22

Slide 22 text

1994

Slide 23

Slide 23 text

Netscape Navigator 1.0

Slide 24

Slide 24 text

1995

Slide 25

Slide 25 text

Web needs to become More dynamic...

Slide 26

Slide 26 text

Netscape hired Brendan Eich

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

To implement Scheme* In the browser

Slide 29

Slide 29 text

+

Slide 30

Slide 30 text

"Why the web needed 2 programming languages?" Java, Scripting Language

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Requirement: Syntax similar to Java

Slide 33

Slide 33 text

Perl Python TCL Scheme

Slide 34

Slide 34 text

Prototype language in 10 days...

Slide 35

Slide 35 text

"We aimed to provide a 'glue language' for the web designers and part-time programmers"

Slide 36

Slide 36 text

1996

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

Alan Cooper Created VBScript

Slide 39

Slide 39 text

Script language for the whole Windows ecosystem*

Slide 40

Slide 40 text

As we are talking about languages...

Slide 41

Slide 41 text

1995

Slide 42

Slide 42 text

Ruby was born...

Slide 43

Slide 43 text

"People want to express themselves when they program. They don't want to fight with the language" (2001, Matz)

Slide 44

Slide 44 text

"You can do everything in assembler, but no one wants to program in assembler anymore" (2003, Matz)

Slide 45

Slide 45 text

We <3 Ruby but...

Slide 46

Slide 46 text

"...no one wants to program in assembler anymore" Can avoid Javascript (2016, Elia Schito)

Slide 47

Slide 47 text

Why Javascript ? ? ?

Slide 48

Slide 48 text

How to organize your code In javascript

Slide 49

Slide 49 text

AMD CommonJS RequireJS *Harmony (ES6) Anonymous Closure Module Pattern Browserify jQuery plugin *DIY StealJS SystemJS

Slide 50

Slide 50 text

Everything in JS is time-sensitive* (and could be incompatible)

Slide 51

Slide 51 text

Frameworks, libraries Everything change from little time to time

Slide 52

Slide 52 text

Packaging and delivery

Slide 53

Slide 53 text

npm (gate) bower jspm volojs jamjs† spmjs† cpm† componentjs†

Slide 54

Slide 54 text

leftpad

Slide 55

Slide 55 text

Options are not but Noise and distraction

Slide 56

Slide 56 text

Why not stick with Ruby?

Slide 57

Slide 57 text

Decaf Browser: Webkit fork that runs Ruby (native) gh: timahoney/decaf

Slide 58

Slide 58 text

Not the best alternative As it's hard to convince every browser...

Slide 59

Slide 59 text

Why not write Ruby In JS?

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

Opal is ~95% RubySpec ready

Slide 62

Slide 62 text

Ruby runtime + Transpiler

Slide 63

Slide 63 text

Native: Arrays, numbers, strings*, boolean, self -> this

Slide 64

Slide 64 text

# this puts "hello rubyconf" # becames: (function(Opal) { var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice; Opal.add_stubs(['$puts']); return self.$puts("Hello RubyConfBr") })(Opal);

Slide 65

Slide 65 text

Packaging and Dependency

Slide 66

Slide 66 text

$ gem install opal-* # With rails, add to your Gemfile and: $ bundle install # In your code: require 'my-awesome-framework'

Slide 67

Slide 67 text

Sprockets Rails Integration:

Slide 68

Slide 68 text

Some libraries To get started...

Slide 69

Slide 69 text

opal-jquery

Slide 70

Slide 70 text

# Gemfile gem 'opal' gem 'opal-jquery' # Your code: Document.ready? do alert "document is ready to go!" end # ... Element.find('#header').on :click do puts "The header was clicked!" end

Slide 71

Slide 71 text

opal-rspec

Slide 72

Slide 72 text

# Gemfile gem 'opal' gem 'opal-rspec' # Your code: describe User do it "can be created with a name" do expect(User.new).to_not be_persisted end end

Slide 73

Slide 73 text

Frameworks

Slide 74

Slide 74 text

Inesita.rb

Slide 75

Slide 75 text

class Clock include Inesita::Component def initialize @time = Time.now end def render div class: 'clock' do text @time.strftime('%r') end end End $document.ready do Clock.new.mount_to($document['clock']) end

Slide 76

Slide 76 text

React.rb

Slide 77

Slide 77 text

class Nav < React::Component::Base def render div {"Our Nav Bar Goes Here including a login box"} end end

Slide 78

Slide 78 text

Perguntas?