Slide 1

Slide 1 text

Nikita THE RUBY SECRET AGENT Brian Ford / @brixen

Slide 2

Slide 2 text

http://www.dailyyonder.com/thin-forests-swell-rural-economy/2009/01/19/1844

Slide 3

Slide 3 text

"Ruby has the best tools" -- No One Ever

Slide 4

Slide 4 text

http://www.lifeoptimizer.org/2008/07/23/being-happy-secrets-of-happy-people/ Ruby is a beautiful language

Slide 5

Slide 5 text

http://www.lifeoptimizer.org/2008/07/23/being-happy-secrets-of-happy-people/ Ruby makes me happy

Slide 6

Slide 6 text

http://ableveterans.com/able-vets-climb-mt-rainier Rails is a terrific framework

Slide 7

Slide 7 text

Ruby is srs bsns !_!

Slide 8

Slide 8 text

Billions of dollars

Slide 9

Slide 9 text

Who here is paid to write Ruby?

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

People are leaving Ruby

Slide 12

Slide 12 text

Node.js Clojure Scala

Slide 13

Slide 13 text

polyglot is the new liberal

Slide 14

Slide 14 text

All the candidates are equally qualified, but you should choose me

Slide 15

Slide 15 text

MRI != Ruby

Slide 16

Slide 16 text

http://icouldntdecide.blogspot.com/

Slide 17

Slide 17 text

http://picasaweb.google.com/lh/photo/bayTKUSuvLPJ8em1oMPbUg This was fun...

Slide 18

Slide 18 text

http://picasaweb.google.com/lh/photo/bayTKUSuvLPJ8em1oMPbUg ...but itʼs sooo slow

Slide 19

Slide 19 text

Business is hard

Slide 20

Slide 20 text

Business is customers

Slide 21

Slide 21 text

Business decisions balance fear and greed

Slide 22

Slide 22 text

Developers are not paid to be happy

Slide 23

Slide 23 text

They are paid to make customers happy

Slide 24

Slide 24 text

If developer happiness and customer happiness collide...

Slide 25

Slide 25 text

"Twitter: From Ruby on Rails to the JVM" http://vimeo.com/29993216 Stop Watch Now

Slide 26

Slide 26 text

Critical Ruby Issues Garbage collection Concurrency Performance Tools

Slide 27

Slide 27 text

U worried bro? http://www.isiticim.com/2010/05/he-was-worried.html

Slide 28

Slide 28 text

Smalltalk was an awesome language http://www.isiticim.com/2010/05/he-was-worried.html

Slide 29

Slide 29 text

am I going to have to use Java again? http://forums.steves-digicams.com/people-photos/150189-sad-little-boy-advice-re-post-production-required.html#b

Slide 30

Slide 30 text

If tools are the answer, what are the questions?

Slide 31

Slide 31 text

How do I understand this code?

Slide 32

Slide 32 text

Fear of the unknown

Slide 33

Slide 33 text

Solutions & Problems Optional Typing Hidden Typing Refinements -w

Slide 34

Slide 34 text

Optional Typing

Slide 35

Slide 35 text

Ruby is about behavior

Slide 36

Slide 36 text

You are what you do

Slide 37

Slide 37 text

ducktyping

Slide 38

Slide 38 text

Classes organize code

Slide 39

Slide 39 text

Classes support encapsulation

Slide 40

Slide 40 text

Three pillars of OO Encapsulation Polymorphism Inheritance

Slide 41

Slide 41 text

Inheritance: relationships between behaviors

Slide 42

Slide 42 text

Hidden Typing Typing requirements that are concealed from Ruby code

Slide 43

Slide 43 text

Not in Ruby

Slide 44

Slide 44 text

Undefined or Not documented

Slide 45

Slide 45 text

Ruby cannot participate

Slide 46

Slide 46 text

VALUE rb_to_float(VALUE val) { if (TYPE(val) == T_FLOAT) return val; if (!rb_obj_is_kind_of(val, rb_cNumeric)) { rb_raise(rb_eTypeError, "can't convert %s into Float", NIL_P(val) ? "nil" : val == Qtrue ? "true" : val == Qfalse ? "false" : rb_obj_classname(val)); } return rb_convert_type(val, T_FLOAT, "Float", "to_f"); }

Slide 47

Slide 47 text

def wrong(a, b) unless a.kind_of? Numeric raise "must be an instance of Numeric" end # ... end

Slide 48

Slide 48 text

Ruby is dictating the structure of programs

Slide 49

Slide 49 text

brittle unnecessary wrong

Slide 50

Slide 50 text

Types tell you what you cannot do

Slide 51

Slide 51 text

Like all walls, people try to defeat them

Slide 52

Slide 52 text

complexity

Slide 53

Slide 53 text

pain

Slide 54

Slide 54 text

Refinements

Slide 55

Slide 55 text

One of the leading proposals...

Slide 56

Slide 56 text

... for ruining Ruby

Slide 57

Slide 57 text

Primary purpose hide incompatible changes

Slide 58

Slide 58 text

naming - powerful abstraction for handling complexity

Slide 59

Slide 59 text

libraries - still need integration testing

Slide 60

Slide 60 text

applications - does not help program comprehension

Slide 61

Slide 61 text

“What if?” programming

Slide 62

Slide 62 text

fear

Slide 63

Slide 63 text

or arrogance

Slide 64

Slide 64 text

horizontal vs vertical integration

Slide 65

Slide 65 text

-w

Slide 66

Slide 66 text

-wtf

Slide 67

Slide 67 text

Hidden in the parser

Slide 68

Slide 68 text

Not Ruby objects

Slide 69

Slide 69 text

No programmatic control

Slide 70

Slide 70 text

Not configurable

Slide 71

Slide 71 text

No real semantic analysis

Slide 72

Slide 72 text

Critical Ruby Issues Garbage collection Concurrency Performance Tools

Slide 73

Slide 73 text

Ruby is bringing a knife to a gunfight

Slide 74

Slide 74 text

Rubinius Foundations Garbage Collection Concurrency Just-in-time Compiler Tools

Slide 75

Slide 75 text

Rubinius Status Update Concurrent threads 1.9 features Windows JIT improvements

Slide 76

Slide 76 text

Rubinius GC

Slide 77

Slide 77 text

Precise

Slide 78

Slide 78 text

Generational

Slide 79

Slide 79 text

Copying Compaction the garbage is never seen

Slide 80

Slide 80 text

Concurrency

Slide 81

Slide 81 text

Fully concurrent Ruby threads

Slide 82

Slide 82 text

concurrent vs parallel

Slide 83

Slide 83 text

hipster Actors since before they were cool

Slide 84

Slide 84 text

Just-in-time FAAAAST

Slide 85

Slide 85 text

OOM

Slide 86

Slide 86 text

Tools

Slide 87

Slide 87 text

Rubinius implements Ruby differently

Slide 88

Slide 88 text

Rubinius uses Ruby

Slide 89

Slide 89 text

Consistent system

Slide 90

Slide 90 text

Trees & Leaves

Slide 91

Slide 91 text

How does Rubinius use Ruby?

Slide 92

Slide 92 text

homoiconic

Slide 93

Slide 93 text

homo - same

Slide 94

Slide 94 text

icon - symbol

Slide 95

Slide 95 text

$ rbx irb(main):001:0> ast = "a = 1".to_ast => # @line=1 @name=:a @variable=nil> irb(main):002:0> ast.class => Rubinius::AST::LocalVariableAssignment

Slide 96

Slide 96 text

$ irb(main):003:0> ast.ascii_graph LocalVariableAssignment @line: 1 @name: :a @variable: nil @value: \ FixnumLiteral @value: 1 @line: 1 => [["@value", #]]

Slide 97

Slide 97 text

$ irb(main):004:0> ast.to_sexp => [:lasgn, :a, [:lit, 1]]

Slide 98

Slide 98 text

$ irb(main):005:0> "a = 1".to_sexp => [:lasgn, :a, [:lit, 1]]

Slide 99

Slide 99 text

What is Ruby?

Slide 100

Slide 100 text

Everything is an object

Slide 101

Slide 101 text

class A a = 1 end module M b = 2 end

Slide 102

Slide 102 text

def m(a) a + b end m { |x| x * 1 }

Slide 103

Slide 103 text

# ruby_script.rb puts "hello"

Slide 104

Slide 104 text

$ rbx irb(main):001:0> def m(a, b) irb(main):002:1> a + b irb(main):003:1> end => #

Slide 105

Slide 105 text

$ rbx compile -e 'puts 1' -B ============= :__script__ ============== Arguments: 0 required, 0 post, 0 total Arity: 0 Locals: 0 Stack size: 2 Lines to IP: 1: 0..8 0000: push_self 0001: meta_push_1 0002: allow_private 0003: send_stack :puts, 1 0006: pop 0007: push_true 0008: ret ----------------------------------------

Slide 106

Slide 106 text

$ rbx compile -e 'class A; def m; end; end' -B -N __script__ ============= :__script__ ============== Arguments: 0 required, 0 post, 0 total Arity: 0 Locals: 0 Stack size: 6 Lines to IP: 1: 0..28 0000: push_rubinius 0001: push_literal :A 0003: push_nil 0004: push_scope 0005: send_stack :open_class, 3 0008: dup_top 0009: push_rubinius 0010: swap_stack 0011: push_literal :__class_init__ 0013: swap_stack 0014: push_literal # 0016: swap_stack 0017: push_scope 0018: swap_stack 0019: send_stack :attach_method, 4 0022: pop 0023: send_stack :__class_init__, 0 0026: pop 0027: push_true 0028: ret ----------------------------------------

Slide 107

Slide 107 text

$ rbx compile -e 'class A; def m; end; end' -B -N A ================== :A ================== Arguments: 0 required, 0 post, 0 total Arity: 0 Locals: 0 Stack size: 5 Lines to IP: 1: 2..15 0000: push_self 0001: add_scope 0002: push_rubinius 0003: push_literal :m 0005: push_literal # 0007: push_scope 0008: push_variables 0009: send_stack :method_visibility, 0 0012: send_stack :add_defn_method, 4 0015: ret ----------------------------------------

Slide 108

Slide 108 text

Everything is a CompiledMethod

Slide 109

Slide 109 text

Rubinius uses Ruby to build a consistent system

Slide 110

Slide 110 text

"Ruby has the best tools" -- No One Ever

Slide 111

Slide 111 text

Nikita

Slide 112

Slide 112 text

my idea of a tool

Slide 113

Slide 113 text

I want you to write tools

Slide 114

Slide 114 text

Architecture Client/Server Separate GUI Data as binding Modular gems

Slide 115

Slide 115 text

CompiledMethod database

Slide 116

Slide 116 text

Class browser

Slide 117

Slide 117 text

Coverage and profiling

Slide 118

Slide 118 text

Bytecode instrumentation

Slide 119

Slide 119 text

$ rbx irb(main):001:0> class F irb(main):002:1> dynamic_method :m do |g| irb(main):003:2* g.push :self irb(main):004:2> g.push_literal g.name irb(main):005:2> g.send :p, 1, true irb(main):006:2> g.ret irb(main):007:2> end irb(main):008:1> end => # irb(main):009:0> F.new.m :m => nil

Slide 120

Slide 120 text

AST transformation

Slide 121

Slide 121 text

Debugging

Slide 122

Slide 122 text

Documentation

Slide 123

Slide 123 text

Analysis variables used before set unused variables misnamed methods code quality

Slide 124

Slide 124 text

Custom tools

Slide 125

Slide 125 text

Summary

Slide 126

Slide 126 text

Ruby is at a critical point

Slide 127

Slide 127 text

I did not change Ruby

Slide 128

Slide 128 text

Available in 1.8 and 1.9

Slide 129

Slide 129 text

Respect business that bet on Ruby

Slide 130

Slide 130 text

http://forums.steves-digicams.com/people-photos/150189-sad-little-boy-advice-re-post-production-required.html#b

Slide 131

Slide 131 text

I don’t want to be this kid. Do you?

Slide 132

Slide 132 text

Help Ruby help you

Slide 133

Slide 133 text

github.com/rubinius/rubinius

Slide 134

Slide 134 text

github.com/brixen/nikita

Slide 135

Slide 135 text

Thank you