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 , 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
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
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 AutoComplete syntactically valid prefix Jungloids [Mandelin et al PLDI ’05] XSnippet [Sahavechaphan et al OOPSLA ’06] input and output types Keyword Programming keywords 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
array List readLine String BufferedReader src BufferedReader add boolean List, String Algorithm
array List readLine String BufferedReader src BufferedReader add boolean List, String Algorithm Function
Algorithm Function Database Dynamic Program Extract Tree
Function Database array List
Function Database array List add boolean List, String
Function Database array List add boolean List, String src BufferedReader
List Functions array List add boolean List, String src BufferedReader readLine String BufferedReader
Function Database array List add boolean List, String src BufferedReader readLine String BufferedReader new String String
Score Functions array List add boolean List, String src BufferedReader readLine String BufferedReader new String String
Score Functions array List add boolean List, String src BufferedReader readLine String BufferedReader new String String add line
1 Score Functions array List add boolean List, String src BufferedReader readLine String BufferedReader new String String add line
Score Functions array List add boolean List, String src BufferedReader readLine String BufferedReader new String String add line 11
Dynamic Program List BufferedReaderString List booleanBufferedReaderString List booleanBufferedReaderString add List, String srcreadLine BufferedReader arrayadd List, String readLine BufferedReader array boolean array src new String src ? array List add boolean List, String src BufferedReader readLine String BufferedReader new String String 11 add List, String
Extract Tree List BufferedReaderString List booleanBufferedReaderString List booleanBufferedReaderString add List, String srcreadLine BufferedReader arrayadd List, String readLine BufferedReader array src new String src 1 2
Extract Tree List BufferedReaderString List booleanBufferedReaderString List booleanBufferedReaderString add List, String srcreadLine BufferedReader arrayadd List, String readLine BufferedReader array src new String src 1 2
Extract Tree List BufferedReaderString List booleanBufferedReaderString List booleanBufferedReaderString add List, String srcreadLine BufferedReader arrayadd List, String readLine BufferedReader array src new String src 1 2
Extract Tree List BufferedReaderString List booleanBufferedReaderString List booleanBufferedReaderString add List, String srcreadLine BufferedReader arrayadd List, String readLine BufferedReader array src new String src 1 2
Extract Tree BufferedReader add List, String arrayreadLine BufferedReader src List String boolean
Render as Java BufferedReader add List, String arrayreadLine BufferedReader src List 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) Discourage double counting
Artificial Corpus sense of speed in real projects sense of accuracy in wide variety of contexts User Study sense of accuracy on real inputs sense for how real inputs look Evaluation
Artificial Corpus Azureus340 kloc Buddi28 kloc CAROL18 kloc Dnsjava17 kloc Jakarta CC10 kloc jEdit125 kloc jMemorize15 kloc Jmol88 kloc JRuby72 kloc Radeox71 kloc RSSOwl71 kloc Sphinx67 kloc TV-Browser120 kloc Zimbra256 kloc multiple open source repositories Popular Could Compile
Artificial Corpus Azureus340 kloc Buddi28 kloc CAROL18 kloc Dnsjava17 kloc Jakarta CC10 kloc jEdit125 kloc jMemorize15 kloc Jmol88 kloc JRuby72 kloc Radeox71 kloc RSSOwl71 kloc Sphinx67 kloc TV-Browser120 kloc Zimbra256 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 name
Artificial Corpus RubySymbol.newSymbol(getRuntime(), name) RubySymbol newSymbol getRuntime name ruby symbol new symbol get runtime name
Artificial Corpus RubySymbol.newSymbol(getRuntime(), name) RubySymbol newSymbol getRuntime name ruby symbol new symbol get runtime name name 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? Record: - match? - how long? - how many keywords? name runtime get symbol symbol ruby new
Results overall 91%
Results under 500ms
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: about 70% students 3 females
User Study
Results Algorithm as-is CorrectIncorrect vowels.indexOf(c)vowels.index(c) vowels.isIn(c) index of c in vowelscheck vowels for c, return neg -1 if c is in vowels vowels search csearch vowels.charAt(c) vowels.indexOf(c,Integer.SIZE)) c
Results Algorithm as-is
Results javakey/pseudo usingas-is using algorithm
Results javakey/pseudo usingas-is53% using algorithm71%53%
Future Work print name of f Integer.valueOf(f.getName()) System.out.print(f.getName()) a priori word weights becomes want of f name print f name
Future Work println f name System.err.println(f.getName()) System.out.println(f.getName()) a priori function weights becomes want println f name println f name
Future Work synonyms lowercase toLowerCase add vs append spell correction
Conclusion array.add(src.readLine());
Backup Slides 70