Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Building Ruby
         in
     Smalltalk
Martin McClure
ESUG 2009
Why?
€
...and more
GemStone
     for
Really Smart
 Dummies
GemStone/S
●   Smalltalk Implementation
●   Headless
●   Shared transactional persistence
       –   Shared “image”
      ...
GemStone/S


   It's
  Just
Smalltalk
The Big Choice
Challenge 1:
The Compiler
Smalltalk Grammar
Ruby Grammar
Ruby 1.8.6 parse.y
Ruby 1.8.6 parse.y
Cheat
Challenge 2:
   Arity
Arity Challenges
●   Number of message send arguments and
    method definition parameters may be
    different.
●
    '*'...
Cheat
Synthetic 'Bridge' Methods
●   def foo(a,*b)
     …
    end
●
    Compiles:
    foo, foo*, foo&, foo*&,
    foo:, foo:*, f...
Synthetic 'Bridge' Methods
●   some_object.foo(a,b,*c)
    compiles a send to selector foo::*
●   Bridge method foo::* ada...
Challenge 3:
Coexistence
of Ruby and
 Smalltalk
Immediate
  Classes
Not
Cheat
Environment-specific behavior
●   Method dictionary per class per environment
●   Each send site specifies an environment
...
Challenge 4:
Per-instance
  Behavior
Challenge 5:
Per-instance
 Variables
In Ruby, an
instance variable
     is created
   by the act of
  assigning to it.
Possible instvars are hard to find
class MyExample
   def initialize(someValue)
     @my_instvar = someValue
   end
end
…
...
Core Tests Passed Over Time
Did we
make the
  right
choice?
Yes
We
Did
Cheat
Not
cheating
 at all,
 really
Thank
   You

Questions?
Building Ruby in Smalltalk
Building Ruby in Smalltalk
Building Ruby in Smalltalk
Building Ruby in Smalltalk
Upcoming SlideShare
Loading in …5
×

Building Ruby in Smalltalk

880 views

Published on

Martin McClure: Building Ruby in
Smalltalk. ESUG 2010, Barcelona, Spain

Published in: Technology
  • Be the first to comment

Building Ruby in Smalltalk

  1. 1. Building Ruby in Smalltalk Martin McClure ESUG 2009
  2. 2. Why?
  3. 3.
  4. 4. ...and more
  5. 5. GemStone for Really Smart Dummies
  6. 6. GemStone/S ● Smalltalk Implementation ● Headless ● Shared transactional persistence – Shared “image” – Commit merges concurrent changes – Large ● Thousands of concurrent VMs ● Terabyte scale – Fast ● 10K commits/sec
  7. 7. GemStone/S It's Just Smalltalk
  8. 8. The Big Choice
  9. 9. Challenge 1: The Compiler
  10. 10. Smalltalk Grammar
  11. 11. Ruby Grammar
  12. 12. Ruby 1.8.6 parse.y
  13. 13. Ruby 1.8.6 parse.y
  14. 14. Cheat
  15. 15. Challenge 2: Arity
  16. 16. Arity Challenges ● Number of message send arguments and method definition parameters may be different. ● '*' Argument and parameter – Array expansion for variable arity ● '&' block passing ● Smalltalk VM expects sender and receiver arity to always be fixed and to match
  17. 17. Cheat
  18. 18. Synthetic 'Bridge' Methods ● def foo(a,*b) … end ● Compiles: foo, foo*, foo&, foo*&, foo:, foo:*, foo:&, foo:*& foo::, foo::*, foo::&, foo::*& foo:::, foo:::*, foo:::&, foo:::*&
  19. 19. Synthetic 'Bridge' Methods ● some_object.foo(a,b,*c) compiles a send to selector foo::* ● Bridge method foo::* adapts number of arguments and resends to actual foo variant
  20. 20. Challenge 3: Coexistence of Ruby and Smalltalk
  21. 21. Immediate Classes
  22. 22. Not Cheat
  23. 23. Environment-specific behavior ● Method dictionary per class per environment ● Each send site specifies an environment ● Complicates full method lookup ● Does not affect send-site caches
  24. 24. Challenge 4: Per-instance Behavior
  25. 25. Challenge 5: Per-instance Variables
  26. 26. In Ruby, an instance variable is created by the act of assigning to it.
  27. 27. Possible instvars are hard to find class MyExample def initialize(someValue) @my_instvar = someValue end end … class MyExample def setAlpha(newAlpha) @alpha = newAlpha end end
  28. 28. Core Tests Passed Over Time
  29. 29. Did we make the right choice?
  30. 30. Yes We Did
  31. 31. Cheat
  32. 32. Not cheating at all, really
  33. 33. Thank You Questions?

×