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
Nikita: The Ruby Secret Agent
Search
brixen
January 29, 2012
Technology
6
1.8k
Nikita: The Ruby Secret Agent
Talk presented at RubyConf 2011.
brixen
January 29, 2012
Tweet
Share
More Decks by brixen
See All by brixen
Stop making mud pies!
brixen
0
85
Papers We Love - Immix mark-region garbage collector
brixen
2
690
An Ensemble of Programming Languages: How to Build a Platform for Collaboration
brixen
0
200
Types As Premature Optimization
brixen
2
490
Rubinius X
brixen
3
270
Code Is What Code Does
brixen
0
400
Augmented Ruby: The Rubinius Language Platform
brixen
2
120
The Future of Ruby
brixen
1
320
Rubinius, and the Future of Ruby
brixen
2
240
Other Decks in Technology
See All in Technology
日本版とグローバル版のモバイルアプリ統合の開発の裏側と今後の展望
miichan
1
130
KubeCon NA 2024 Recap: How to Move from Ingress to Gateway API with Minimal Hassle
ysakotch
0
200
Turing × atmaCup #18 - 1st Place Solution
hakubishin3
0
480
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
330
Snowflake女子会#3 Snowpipeの良さを5分で語るよ
lana2548
0
230
NilAway による静的解析で「10 億ドル」を節約する #kyotogo / Kyoto Go 56th
ytaka23
3
380
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
9
7.7k
re:Invent 2024 Innovation Talks(NET201)で語られた大切なこと
shotashiratori
0
310
C++26 エラー性動作
faithandbrave
2
730
AI時代のデータセンターネットワーク
lycorptech_jp
PRO
1
280
サイバー攻撃を想定したセキュリティガイドライン 策定とASM及びCNAPPの活用方法
syoshie
3
1.3k
複雑性の高いオブジェクト編集に向き合う: プラガブルなReactフォーム設計
righttouch
PRO
0
110
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Speed Design
sergeychernyshev
25
670
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
520
Fireside Chat
paigeccino
34
3.1k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Practical Orchestrator
shlominoach
186
10k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
Music & Morning Musume
bryan
46
6.2k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Transcript
Nikita THE RUBY SECRET AGENT Brian Ford / @brixen
http://www.dailyyonder.com/thin-forests-swell-rural-economy/2009/01/19/1844
"Ruby has the best tools" -- No One Ever
http://www.lifeoptimizer.org/2008/07/23/being-happy-secrets-of-happy-people/ Ruby is a beautiful language
http://www.lifeoptimizer.org/2008/07/23/being-happy-secrets-of-happy-people/ Ruby makes me happy
http://ableveterans.com/able-vets-climb-mt-rainier Rails is a terrific framework
Ruby is srs bsns !_!
Billions of dollars
Who here is paid to write Ruby?
None
People are leaving Ruby
Node.js Clojure Scala
polyglot is the new liberal
All the candidates are equally qualified, but you should choose
me
MRI != Ruby
http://icouldntdecide.blogspot.com/
http://picasaweb.google.com/lh/photo/bayTKUSuvLPJ8em1oMPbUg This was fun...
http://picasaweb.google.com/lh/photo/bayTKUSuvLPJ8em1oMPbUg ...but itʼs sooo slow
Business is hard
Business is customers
Business decisions balance fear and greed
Developers are not paid to be happy
They are paid to make customers happy
If developer happiness and customer happiness collide...
"Twitter: From Ruby on Rails to the JVM" http://vimeo.com/29993216 Stop
Watch Now
Critical Ruby Issues Garbage collection Concurrency Performance Tools
U worried bro? http://www.isiticim.com/2010/05/he-was-worried.html
Smalltalk was an awesome language http://www.isiticim.com/2010/05/he-was-worried.html
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
If tools are the answer, what are the questions?
How do I understand this code?
Fear of the unknown
Solutions & Problems Optional Typing Hidden Typing Refinements -w
Optional Typing
Ruby is about behavior
You are what you do
ducktyping
Classes organize code
Classes support encapsulation
Three pillars of OO Encapsulation Polymorphism Inheritance
Inheritance: relationships between behaviors
Hidden Typing Typing requirements that are concealed from Ruby code
Not in Ruby
Undefined or Not documented
Ruby cannot participate
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"); }
def wrong(a, b) unless a.kind_of? Numeric raise "must be an
instance of Numeric" end # ... end
Ruby is dictating the structure of programs
brittle unnecessary wrong
Types tell you what you cannot do
Like all walls, people try to defeat them
complexity
pain
Refinements
One of the leading proposals...
... for ruining Ruby
Primary purpose hide incompatible changes
naming - powerful abstraction for handling complexity
libraries - still need integration testing
applications - does not help program comprehension
“What if?” programming
fear
or arrogance
horizontal vs vertical integration
-w
-wtf
Hidden in the parser
Not Ruby objects
No programmatic control
Not configurable
No real semantic analysis
Critical Ruby Issues Garbage collection Concurrency Performance Tools
Ruby is bringing a knife to a gunfight
Rubinius Foundations Garbage Collection Concurrency Just-in-time Compiler Tools
Rubinius Status Update Concurrent threads 1.9 features Windows JIT improvements
Rubinius GC
Precise
Generational
Copying Compaction the garbage is never seen
Concurrency
Fully concurrent Ruby threads
concurrent vs parallel
hipster Actors since before they were cool
Just-in-time FAAAAST
OOM
Tools
Rubinius implements Ruby differently
Rubinius uses Ruby
Consistent system
Trees & Leaves
How does Rubinius use Ruby?
homoiconic
homo - same
icon - symbol
$ rbx irb(main):001:0> ast = "a = 1".to_ast => #<Rubinius::AST::LocalVariableAssignment:0xf30
@value=#<Rubinius::AST::FixnumLiteral:0xf34 @value=1 @line=1> @line=1 @name=:a @variable=nil> irb(main):002:0> ast.class => Rubinius::AST::LocalVariableAssignment
$ irb(main):003:0> ast.ascii_graph LocalVariableAssignment @line: 1 @name: :a @variable: nil
@value: \ FixnumLiteral @value: 1 @line: 1 => [["@value", #<Rubinius::AST::FixnumLiteral:0xf34 @value=1 @line=1>]]
$ irb(main):004:0> ast.to_sexp => [:lasgn, :a, [:lit, 1]]
$ irb(main):005:0> "a = 1".to_sexp => [:lasgn, :a, [:lit, 1]]
What is Ruby?
Everything is an object
class A a = 1 end module M b =
2 end
def m(a) a + b end m { |x| x
* 1 }
# ruby_script.rb puts "hello"
$ rbx irb(main):001:0> def m(a, b) irb(main):002:1> a + b
irb(main):003:1> end => #<Rubinius::CompiledMethod m file=(irb)>
$ 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 ----------------------------------------
$ 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 #<Rubinius::CompiledMethod A file=(snippet)> 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 ----------------------------------------
$ 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 #<Rubinius::CompiledMethod m file=(snippet)> 0007: push_scope 0008: push_variables 0009: send_stack :method_visibility, 0 0012: send_stack :add_defn_method, 4 0015: ret ----------------------------------------
Everything is a CompiledMethod
Rubinius uses Ruby to build a consistent system
"Ruby has the best tools" -- No One Ever
Nikita
my idea of a tool
I want you to write tools
Architecture Client/Server Separate GUI Data as binding Modular gems
CompiledMethod database
Class browser
Coverage and profiling
Bytecode instrumentation
$ 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 => #<Rubinius::CompiledMethod m file=dynamic> irb(main):009:0> F.new.m :m => nil
AST transformation
Debugging
Documentation
Analysis variables used before set unused variables misnamed methods code
quality
Custom tools
Summary
Ruby is at a critical point
I did not change Ruby
Available in 1.8 and 1.9
Respect business that bet on Ruby
http://forums.steves-digicams.com/people-photos/150189-sad-little-boy-advice-re-post-production-required.html#b
I don’t want to be this kid. Do you?
Help Ruby help you
github.com/rubinius/rubinius
github.com/brixen/nikita
Thank you