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

100 %
0 %
Information about Summer of Code 2006: Ruby Type Inference & Code Completion for RDT

Published on December 27, 2007

Author: jmorrison

Source: slideshare.net

Description

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.

Ruby Type Inference & Code Completion for RDT Google Summer of Code Jason Morrison

Overview Project Goals Why Eclipse and Java? Completion Features Type Inference Algorithm Issues The Future

Project Goals

Why Eclipse and Java?

Completion Features

Type Inference Algorithm

Issues

The Future

Project Goals

Project Goals Code completion for RDT I’m lazy; Ruby is great and succinct, but… And, it helps other developers!

Code completion for RDT

I’m lazy; Ruby is great and succinct, but…

And, it helps other developers!

Project Goals Ruby type inference It’s fun! (Read: I knew very little about it) Alternative implementation performance Priming the cache for polymorphic dispatch

Ruby type inference

It’s fun! (Read: I knew very little about it)

Alternative implementation performance

Priming the cache for polymorphic dispatch

Why Eclipse and Java?

 

 

 

 

 

“ Eclipse is too big!”

 

“ It’s bloated! :P”

 

Not targeting that guy

Convert the natives!

Completion Features

Completion Features Scoped object completion Method completion

Scoped object completion

Method completion

Scoped Object Completion Locals, Block Locals @, @@, $ Pre-defined variables $_, $:, $”, $0 and friends Available classes

Locals, Block Locals

@, @@, $

Pre-defined variables

$_, $:, $”, $0 and friends

Available classes

Scoped Object Completion Tricky spots: Open classes No explicit declaration set_instance_var and friends

Tricky spots:

Open classes

No explicit declaration

set_instance_var and friends

Method Completion Invocations are message passing Type is a bag of possible methods Selector [Args] [Confidence]

Invocations are message passing

Type is a bag of possible methods

Selector

[Args]

[Confidence]

Method Completion Many scoping and definition syntaxes: class Foo;def method;… instance_eval… class_eval… define_method… include FooModule Object#extend(module) class << self; def method;… method_missing…

Many scoping and definition syntaxes:

class Foo;def method;…

instance_eval…

class_eval…

define_method…

include FooModule

Object#extend(module)

class << self; def method;…

method_missing…

Type Inference Algorithm

What is Type Inference? Determine the type of an expression Static analysis Type versus Class Not always definitive

Determine the type of an expression

Static analysis

Type versus Class

Not always definitive

Type Inference Algorithm Inspired by DDP by Lex Spoon: Demand-Driven Analysis with Goal Pruning Type flow analysis Unions types over contours

Inspired by DDP by Lex Spoon:

Demand-Driven Analysis with Goal Pruning

Type flow analysis

Unions types over contours

DDP Structure Posts goals Goals have sub-goals Answered by judgements Prunes low value goals High cost Low impact on high level goals

Posts goals

Goals have sub-goals

Answered by judgements

Prunes low value goals

High cost

Low impact on high level goals

DDP Goals 1. Type goal What is the type of x? 2. Transitive flow Where can objects flow from x? 3. Simple flow Where can objects flow from x in one step? 4. Sender What statements invoke FooClass#bar? 5. Responder What methods are invoked by &quot;foo.bar&quot;?

1. Type goal

What is the type of x?

2. Transitive flow

Where can objects flow from x?

3. Simple flow

Where can objects flow from x in one step?

4. Sender

What statements invoke FooClass#bar?

5. Responder

What methods are invoked by &quot;foo.bar&quot;?

DataFlowTypeInferrer infer(String source, int offset) findSenders(String scope, String selector) findMethodDef(String scope, String selector)

infer(String source, int offset)

findSenders(String scope, String selector)

findMethodDef(String scope, String selector)

DataFlowTypeInferrer

Issues Eval Data-bound flow control return ( rand() > 0.5 ) ? String.new : Array.new Metaprogramming Collections Builtins

Eval

Data-bound flow control

return ( rand() > 0.5 ) ? String.new : Array.new

Metaprogramming

Collections

Builtins

The Future Statistical type inference Type metadata (collections) Rails tie-in AR querying for magic find Instance vars in View templates TI for implementation optimizations

Statistical type inference

Type metadata (collections)

Rails tie-in

AR querying for magic find

Instance vars in View templates

TI for implementation optimizations

Thanks! Chris Williams, project mentor! Google Summer of Code Everyone on the RDT and JRuby teams All the folks at RubyCentral

Chris Williams, project mentor!

Google Summer of Code

Everyone on the RDT and JRuby teams

All the folks at RubyCentral

Q&A Jason Morrison [email_address] http://soc.jayunit.net

Jason Morrison

[email_address]

http://soc.jayunit.net

Add a comment

Related presentations

Related pages

Rdt | LinkedIn

View 8516 Rdt posts, presentations, ... add your area code, ... Summer of Code 2006: Ruby Type Inference & Code Completion for RDT.
Read more

Ruby Type Inference and Code Completion for RDT - Jason ...

I gave a talk at RubyConf 2006, detailing my project for the Google Summer of Code 2006. I worked on type inference for the purpose of code completion in ...
Read more

RubyConf 2006—Day 3 (Sunday, 22 October 2006) // halo • statue

... RubyConf 2006. ... I gave a quick introduction to the Google Summer of Code ... Jason Morrison spoke on Ruby Type Inference & Code Completion for RDT.
Read more

Graph-Based Code Completion - Education

... ContextSensitive Source Code Completion Nguyen ... Unresolved nodes assigned ‘Unknown Type ... Summer of Code 2006: Ruby Type Inference & Code ...
Read more

Program Comprehension - An Evaluation of the Strategies of ...

... and Grouping API Methods for Code Completion Authors: ... •Contact me for BCC source code ... Summer of Code 2006: Ruby Type Inference & Code ...
Read more

B Tech - Biotech - scribd.com

... Programme Code: BTB Duration ... The curriculum has an inbuilt system of industrial summer training which keeps students ... Type of Polymorphism ...
Read more

114th Annual Meeting of the American Associaton of ...

... Pharmacogenomics.is rapidly evolving area helping optimize medication therapy using an individual's genetic code to ... completion as compared to the ...
Read more

Career | JobsAndCareer.com

career advice, tips, news and discussion is coming soon More Career Information. Salaries; Interview Questions ; Sample Resumes; Jobs
Read more