Building Ruby in Smalltalk

727 views
677 views

Published on

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

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
727
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

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?

×