Keyword Programming in Java

Post on 02-Jan-2016

30 views 0 download

Tags:

description

Keyword Programming in Java. Greg Little and Robert C. Miller MIT CSAIL This work was supported in part by the National Science Foundation under award number IIS-0447800, and by Quanta Computer as part of the TParty project. Keyword Programming. Problem. src. array. cursor. - PowerPoint PPT Presentation

Transcript of Keyword Programming in Java

Keyword Programming in Java

Greg Little and Robert C. MillerMIT CSAIL

This work was supported in part by the National Science Foundation under award number IIS-0447800,and by Quanta Computer as part of the TParty project.

Keyword Programming

Problem

src

read a line from src,and add it to array

array

cursor

AutoComplete

read a line from src,and add it to array

AutoComplete

read a line from src,and add it to array

read a line from src,and add it to array

AutoComplete

AutoComplete

read a line from src,and add it to array

AutoComplete

read a line from src,and add it to array

read a line from src,and add it to array

AutoComplete

read a line from src,and add it to array

AutoComplete

AutoComplete

read a line from src,and add it to array

Keyword Programming

read a line from src,and add it to array

Keyword Programming

read a line from src,and add it to array

Keyword Programming

read a line from src,and add it to array

Keyword Programming

read a line from src,and add it to array

Keyword Programming

read a line from src,and add it to array

Related Work

AutoCompletesyntactically valid prefix

Jungloids [Mandelin et al PLDI ’05]

XSnippet [Sahavechaphan et al OOPSLA ’06]

input and output types

Keyword Programmingkeywords from expression

Motivation

Overview

• Algorithm

• Evaluation

Algorithm

array.add(src.readLine());

array.add(src.readLine);

array readLine

src

Algorithm

array.add(src.readLine);

array readLine

src

Algorithm

BufferedReader

StringList<String>

arrayList<String>

readLineString

BufferedReader

srcBufferedReader

addboolean

List<String>, String

Algorithm

arrayList<String>

readLineString

BufferedReader

srcBufferedReader

addboolean

List<String>, String

Algorithm

Function

Algorithm

Function Database

Dynamic Program

Extract Tree

Function Database

arrayList<String>

Function Database

arrayList<String>

addboolean

List<String>, String

Function Database

arrayList<String>

addboolean

List<String>, Stringsrc

BufferedReader

List Functions

arrayList<String>

addboolean

List<String>, Stringsrc

BufferedReaderreadLine

String

BufferedReader

Function Database

arrayList<String>

addboolean

List<String>, Stringsrc

BufferedReaderreadLine

String

BufferedReader

new StringString

Score Functions

arrayList<String>

addboolean

List<String>, Stringsrc

BufferedReaderreadLine

String

BufferedReader

new StringString

Score Functions

arrayList<String>

addboolean

List<String>, Stringsrc

BufferedReaderreadLine

String

BufferedReader

new StringString

add line

1

Score Functions

arrayList<String>

addboolean

List<String>, Stringsrc

BufferedReaderreadLine

String

BufferedReader

new StringString

add line

Score Functions

arrayList<String>

addboolean

List<String>, Stringsrc

BufferedReaderreadLine

String

BufferedReader

new StringString

add line

11

Dynamic Program

List<String> BufferedReader String

List<String> boolean BufferedReader String

List<String> boolean BufferedReader Stringadd

List<String>, Stringsrc readLine

BufferedReader

array addList<String>, String

readLineBufferedReader

arrayboolean

array

src new String

src

?

arrayList<String>

addboolean

List<String>, Stringsrc

BufferedReaderreadLine

String

BufferedReader

new StringString

11

addList<String>, String

1

1

1

1

1

1 1

12

1

Extract Tree

List<String> BufferedReader String

List<String> boolean BufferedReader String

List<String> boolean BufferedReader Stringadd

List<String>, Stringsrc readLine

BufferedReader

array addList<String>, String

readLineBufferedReader

array

array

src new String

src

12

Extract Tree

List<String> BufferedReader String

List<String> boolean BufferedReader String

List<String> boolean BufferedReader Stringadd

List<String>, Stringsrc readLine

BufferedReader

array addList<String>, String

readLineBufferedReader

array

array

src new String

src

12

Extract Tree

List<String> BufferedReader String

List<String> boolean BufferedReader String

List<String> boolean BufferedReader Stringadd

List<String>, Stringsrc readLine

BufferedReader

array addList<String>, String

readLineBufferedReader

array

array

src new String

src

12

Extract Tree

List<String> BufferedReader String

List<String> boolean BufferedReader String

List<String> boolean BufferedReader Stringadd

List<String>, Stringsrc readLine

BufferedReader

array addList<String>, String

readLineBufferedReader

array

array

src new String

src

12

Extract Tree

BufferedReader

addList<String>, String

array readLineBufferedReader

src

List<String> String

boolean

Render as Java

BufferedReader

addList<String>, String

array readLineBufferedReader

src

List<String> String

boolean

array.add(src.readLine())

More Complex

.Math.max(x, y)..........

Keep best n functions per box

max x y . .Math.max(x, x)..........

3

Discourage double counting

Artificial Corpussense of speed in real projectssense of accuracy in wide variety of contexts

User Studysense of accuracy on real inputssense for how real inputs look

Evaluation

Artificial Corpus

Azureus 340 kloc

Buddi 28 kloc

CAROL 18 kloc

Dnsjava 17 kloc

Jakarta CC 10 kloc

jEdit 125 kloc

jMemorize 15 kloc

Jmol 88 kloc

JRuby 72 kloc

Radeox 71 kloc

RSSOwl 71 kloc

Sphinx 67 kloc

TV-Browser 120 kloc

Zimbra 256 kloc

multiple open source repositories

Popular

Could Compile

Artificial Corpus

Azureus 340 kloc

Buddi 28 kloc

CAROL 18 kloc

Dnsjava 17 kloc

Jakarta CC 10 kloc

jEdit 125 kloc

jMemorize 15 kloc

Jmol 88 kloc

JRuby 72 kloc

Radeox 71 kloc

RSSOwl 71 kloc

Sphinx 67 kloc

TV-Browser 120 kloc

Zimbra 256 kloc

Artificial Corpus

RubySymbol.newSymbol(getRuntime(), name)

Artificial Corpus

RubySymbol.newSymbol(getRuntime(), name)

RubySymbol newSymbol getRuntime name

Artificial Corpus

RubySymbol.newSymbol(getRuntime(), name)

RubySymbol newSymbol getRuntime nameRuby Symbol new Symbol get Runtime name

Artificial Corpus

RubySymbol.newSymbol(getRuntime(), name)

RubySymbol newSymbol getRuntime nameRuby Symbol new Symbol get Runtime nameruby symbol new symbol get runtime name

Artificial Corpus

RubySymbol.newSymbol(getRuntime(), name)

RubySymbol newSymbol getRuntime nameRuby Symbol new Symbol get Runtime nameruby symbol new symbol get runtime namename runtime get symbol symbol ruby new

Artificial Corpus

RubySymbol.newSymbol(getRuntime(), name)

name runtime get symbol symbol ruby new

Artificial Corpus

RubySymbol.newSymbol(getRuntime(), name)

name runtime get symbol symbol ruby new

Algorithm

Artificial Corpus

RubySymbol.newSymbol(getRuntime(), name)

Algorithm

name runtime get symbol symbol ruby new

Artificial Corpus

RubySymbol.newSymbol(getRuntime(), name)

Algorithm

Record:- match?- how long?- how many keywords?

name runtime get symbol symbol ruby new

Results

overall 91%

Results

under 500ms

Results

Results

User Study

solicited experienced Java programmers (from college mailing lists)

motivated with money—chance to win $20

web based study

good data for 49 participants

ages: 18 - 74

about 70% students

3 females

User Study

User Study

ResultsA

lgori

thm

as-isCorrect Incorrect

vowels.indexOf(c) vowels.index(c)

vowels.index(c) vowels.isIn(c)

index of c in vowels check vowels for c, return neg -1 if c is in vowels

vowels search c search

vowels.charAt(c)

vowels.indexOf(c,Integer.SIZE))

c

Results

Alg

ori

thm

as-is

Results

java key/pseudo

using as-is

using algorithm

Results

java key/pseudo

using as-is 53%

using algorithm 71% 53%

Future Work

print name of f

Integer.valueOf(f.getName())

System.out.print(f.getName())

a priori word weights

becomeswant

offname

printfname

1113

1113

Future Work

println f name

System.err.println(f.getName())

System.out.println(f.getName())

a priori function weights

becomes

want

printlnfname

1113

printlnfname

1113

Future Work

synonyms

lowercase toLowerCase

add vs append

spell correction

Conclusion

array.add(src.readLine());

Backup Slides

70

E-mail

glittle@gmail.com