Ruby Type Inference & Code Completion for RDT Google Summer of Code Jason Morrison
Overview <ul><li>Project Goals </li></ul><ul><li>Why Eclipse and Java? </li></ul><ul><li>Completion Features </li></ul><ul...
Project Goals
Project Goals <ul><li>Code completion for RDT </li></ul><ul><ul><li>I’m lazy; Ruby is great and succinct, but… </li></ul><...
Project Goals <ul><li>Ruby type inference </li></ul><ul><ul><li>It’s fun! (Read: I knew very little about it) </li></ul></...
Why Eclipse and Java?
 
 
 
 
 
“ Eclipse is too big!”
 
“ It’s bloated! :P”
 
Not targeting that guy
Convert the natives!
Completion Features
Completion Features <ul><li>Scoped object completion </li></ul><ul><li>Method completion </li></ul>
Scoped Object Completion <ul><li>Locals, Block Locals </li></ul><ul><li>@, @@, $ </li></ul><ul><li>Pre-defined variables <...
Scoped Object Completion <ul><li>Tricky spots: </li></ul><ul><ul><li>Open classes </li></ul></ul><ul><ul><li>No explicit d...
Method Completion <ul><li>Invocations are message passing </li></ul><ul><li>Type is a bag of possible methods </li></ul><u...
Method Completion <ul><li>Many scoping and definition syntaxes: </li></ul><ul><ul><li>class Foo;def method;… </li></ul></u...
Type Inference Algorithm
What is Type Inference? <ul><li>Determine the type of an expression </li></ul><ul><li>Static analysis </li></ul><ul><li>Ty...
Type Inference Algorithm <ul><li>Inspired by DDP by Lex Spoon: </li></ul><ul><ul><li>Demand-Driven Analysis with Goal Prun...
DDP Structure <ul><li>Posts goals </li></ul><ul><li>Goals have sub-goals </li></ul><ul><li>Answered by judgements </li></u...
DDP Goals <ul><li>1. Type goal </li></ul><ul><ul><li>What is the type of x? </li></ul></ul><ul><li>2. Transitive flow </li...
DataFlowTypeInferrer <ul><li>infer(String source, int offset) </li></ul><ul><li>findSenders(String scope, String selector)...
DataFlowTypeInferrer
Issues <ul><li>Eval </li></ul><ul><li>Data-bound flow control </li></ul><ul><ul><li>return ( rand() > 0.5 ) ? String.new :...
The Future <ul><li>Statistical type inference </li></ul><ul><li>Type metadata (collections) </li></ul><ul><li>Rails tie-in...
Thanks! <ul><li>Chris Williams, project mentor! </li></ul><ul><li>Google Summer of Code </li></ul><ul><li>Everyone on the ...
Q&A <ul><li>Jason Morrison </li></ul><ul><li>[email_address] </li></ul><ul><li>http://soc.jayunit.net </li></ul>
Upcoming SlideShare
Loading in...5
×

Summer of Code 2006: Ruby Type Inference & Code Completion for RDT

1,662

Published on

A discussion of my contributions to the Ruby Development Tool regarding type inference for the purpose of code completion. Given at RubyConf 2006, work done for Google Summer of Code 2006.

Published in: Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,662
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Summer of Code 2006: Ruby Type Inference & Code Completion for RDT

  1. 1. Ruby Type Inference & Code Completion for RDT Google Summer of Code Jason Morrison
  2. 2. Overview <ul><li>Project Goals </li></ul><ul><li>Why Eclipse and Java? </li></ul><ul><li>Completion Features </li></ul><ul><li>Type Inference Algorithm </li></ul><ul><li>Issues </li></ul><ul><li>The Future </li></ul>
  3. 3. Project Goals
  4. 4. Project Goals <ul><li>Code completion for RDT </li></ul><ul><ul><li>I’m lazy; Ruby is great and succinct, but… </li></ul></ul><ul><ul><li>And, it helps other developers! </li></ul></ul>
  5. 5. Project Goals <ul><li>Ruby type inference </li></ul><ul><ul><li>It’s fun! (Read: I knew very little about it) </li></ul></ul><ul><ul><li>Alternative implementation performance </li></ul></ul><ul><ul><ul><li>Priming the cache for polymorphic dispatch </li></ul></ul></ul>
  6. 6. Why Eclipse and Java?
  7. 12. “ Eclipse is too big!”
  8. 14. “ It’s bloated! :P”
  9. 16. Not targeting that guy
  10. 17. Convert the natives!
  11. 18. Completion Features
  12. 19. Completion Features <ul><li>Scoped object completion </li></ul><ul><li>Method completion </li></ul>
  13. 20. Scoped Object Completion <ul><li>Locals, Block Locals </li></ul><ul><li>@, @@, $ </li></ul><ul><li>Pre-defined variables </li></ul><ul><ul><li>$_, $:, $”, $0 and friends </li></ul></ul><ul><li>Available classes </li></ul>
  14. 21. Scoped Object Completion <ul><li>Tricky spots: </li></ul><ul><ul><li>Open classes </li></ul></ul><ul><ul><li>No explicit declaration </li></ul></ul><ul><ul><li>set_instance_var and friends </li></ul></ul>
  15. 22. Method Completion <ul><li>Invocations are message passing </li></ul><ul><li>Type is a bag of possible methods </li></ul><ul><ul><li>Selector </li></ul></ul><ul><ul><li>[Args] </li></ul></ul><ul><ul><li>[Confidence] </li></ul></ul>
  16. 23. Method Completion <ul><li>Many scoping and definition syntaxes: </li></ul><ul><ul><li>class Foo;def method;… </li></ul></ul><ul><ul><li>instance_eval… </li></ul></ul><ul><ul><li>class_eval… </li></ul></ul><ul><ul><li>define_method… </li></ul></ul><ul><ul><li>include FooModule </li></ul></ul><ul><ul><li>Object#extend(module) </li></ul></ul><ul><ul><li>class << self; def method;… </li></ul></ul><ul><ul><li>method_missing… </li></ul></ul>
  17. 24. Type Inference Algorithm
  18. 25. What is Type Inference? <ul><li>Determine the type of an expression </li></ul><ul><li>Static analysis </li></ul><ul><li>Type versus Class </li></ul><ul><li>Not always definitive </li></ul>
  19. 26. Type Inference Algorithm <ul><li>Inspired by DDP by Lex Spoon: </li></ul><ul><ul><li>Demand-Driven Analysis with Goal Pruning </li></ul></ul><ul><li>Type flow analysis </li></ul><ul><li>Unions types over contours </li></ul>
  20. 27. DDP Structure <ul><li>Posts goals </li></ul><ul><li>Goals have sub-goals </li></ul><ul><li>Answered by judgements </li></ul><ul><li>Prunes low value goals </li></ul><ul><ul><li>High cost </li></ul></ul><ul><ul><li>Low impact on high level goals </li></ul></ul>
  21. 28. DDP Goals <ul><li>1. Type goal </li></ul><ul><ul><li>What is the type of x? </li></ul></ul><ul><li>2. Transitive flow </li></ul><ul><ul><li>Where can objects flow from x? </li></ul></ul><ul><li>3. Simple flow </li></ul><ul><ul><li>Where can objects flow from x in one step? </li></ul></ul><ul><li>4. Sender </li></ul><ul><ul><li>What statements invoke FooClass#bar? </li></ul></ul><ul><li>5. Responder </li></ul><ul><ul><li>What methods are invoked by &quot;foo.bar&quot;? </li></ul></ul>
  22. 29. DataFlowTypeInferrer <ul><li>infer(String source, int offset) </li></ul><ul><li>findSenders(String scope, String selector) </li></ul><ul><li>findMethodDef(String scope, String selector) </li></ul>
  23. 30. DataFlowTypeInferrer
  24. 31. Issues <ul><li>Eval </li></ul><ul><li>Data-bound flow control </li></ul><ul><ul><li>return ( rand() > 0.5 ) ? String.new : Array.new </li></ul></ul><ul><li>Metaprogramming </li></ul><ul><li>Collections </li></ul><ul><li>Builtins </li></ul>
  25. 32. The Future <ul><li>Statistical type inference </li></ul><ul><li>Type metadata (collections) </li></ul><ul><li>Rails tie-in </li></ul><ul><ul><li>AR querying for magic find </li></ul></ul><ul><ul><li>Instance vars in View templates </li></ul></ul><ul><li>TI for implementation optimizations </li></ul>
  26. 33. Thanks! <ul><li>Chris Williams, project mentor! </li></ul><ul><li>Google Summer of Code </li></ul><ul><li>Everyone on the RDT and JRuby teams </li></ul><ul><li>All the folks at RubyCentral </li></ul>
  27. 34. Q&A <ul><li>Jason Morrison </li></ul><ul><li>[email_address] </li></ul><ul><li>http://soc.jayunit.net </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×