What do you see yourself doing after you earn your Bachelor’s? INTERACTIVE PROGRAM A. Get a job as a programmer/tester etc., on the tech track B. Get a job with the government TRANSFORMATIONS C. Go to grad school (M.S. or Ph.D.) D. Start my own company E. Other Danny Dig 2 What can I do today so that I get my dream SE Software Evolution as Done Today job next year? Create a folder/CV with your CS361 work (professional Change is the heart of software development: documentation, process, TDD, Design Patterns) - add features, fix bugs, support new hardware/UI/OS Write lots of code (read even more code) Today’s program development is very crude - change carried manually, through low-level edits Contribute to OSS - changes are almost never reused - your CV is your GitHub profile - versioning tools focus on changes to lines of code Change is too ad-hoc making software development error- prone, time-consuming, and $$$ - 2/3 rd of software costs due to software evolution, some industrial surveys claiming 90% 3 4 My View of Tomorrow: Interactive Source-to-Source Programming is Program Transformation Program Transformations Change needs to move to a higher-level of abstraction Program transformations as first-class: - most changes carried through automated program transformations domain - even manual edits become transformations search, remember, knowledge compute - programs as sequence of program transformations Q1: Analyze what software changes occur in practice? Q2: How can we automate them? Programmer + Tool >> Tool | Programmer Q3: Can we represent programs as transformations? Archive, retrieve, and visualize them? Q4: Can we infer higher-level transformations? 5 6 1
Refactoring Code for Overview of My Research Asynchronous Execution on Mobile Retrofit Parallelism Introduce Asynchronous Code By 2016, 300B apps downloaded annually TOSEM15,STVR15, ICSE14, FSE14 Running I/O blocking operations synchronously freezes the UI ECOOP14,ISSTA13, and frustrates users FSE13,ICST13,FSE12, Interactive ICSE11,SOFTW11, Analysis & Transformations OOPSLA09, My research enables retrofitting asynchronous execution via ICSE09, ASE09a interactive refactoring (complex analysis and transformation) - inverting flow of control, callbacks Upgrade library-based Refactor end-user software programs - novel analyses determine non-interference with main thread ECOOP13,ECOOP12, FSE14d,ICSM12 Generate tests TSE08, ICSE08, Generated hundreds of patches to correctly introduce ICSE07,ECOOP06, ICST13, TSE10, asynchrony, accepted by OSS developers JSME06,ICSM05 ASE09b, ISSTA08, FSE07 7 8 From Imperative to Functional Programming through Our Refactorings for Parallelism Refactoring [ Gyori, Franklin, Dig, Lahoda: FSE’13 ] Refactorings for thread-safety Interprocedural λ expressions x, y -> x + y - make class immutable [ICSE'11] analyses: - convert to Atomic* classes [ICSE'09] - control, data-flow - use concurrent collections [ICSE'09] - points-to Hallmark of functional languages - infer region annotations [ASE'09] - constraint-based - atomic check-then-act operations [ICST’13] Some languages had λ from first version (Smalltalk, Refactorings for throughput Python, JS) - parallel recursive divide-and-conquer [ICSE'09] - loop parallelism via ParallelArray [OOPSLA’10] λ retrofitted in OO languages (C++, C#, Java) - loop parallelism via lambda-enabled functional operators - unobtrusive parallelism [FSE’13] - collections Refactorings for scalability - Atomic*, concurrent collections [ICSE'09] 9 10 Advantages of iterating with functional How can I λ - ify my Java code? 1. private void redify() { operations 2. int n = 4; // amount of parallelism 3. Thread[] threads = new LambdaFicator refactorings: private void redify() { Thread[n]; 4. final List<ElementRule> rules = for ( Block b : blocks) 5. if(b.getColor() == BLUE) properties.getRules(); Cleaner code 6. int size = rules.size(); b.setColor(RED); 1. Anonymous Inner Class to lambda 7. for ( int i = 0; i < n; i++) { 8. final int from = i * size / n; Less clutter } 9. final int to = (i + 1) * size / n; 10. threads[i] = new Thread(new Runnable() { 11. @Override private void redify() { 12. public void run() { 13. for ( Block b : blocks.parallelStream() blocks) unobtrusive parallelism 14. if(b.getColor() == .filter(b -> b.getColor() == BLUE) 2. for loop to functional operations BLUE) explicit semantics .forEach(b -> { b.setColor(RED); }); 15. b.setColor(RED); } 16. } 17. }); External Iteration -> Internal Iteration 18. threads[i].start(); 19. } 20. for ( int i = 0; i < n; i++) { 21. try { DEMO 22. threads[i].join(); 11 23. } catch ( InterruptedException ex) { 2
Refactoring meets Spreadsheets Empirical evaluation [Badame, Dig – ICSM’12] Spreadsheets have been around for 4,000 years We ran LambdaFicator on 10 projects, ~1Million SLOC - Plimpton 322, Babylonian clay tablet showing the Pythagorean triplets, 1800BC Refactorings are widely applicable - 46% of for loops successfully refactored Refactorings improve code quality: - first refactoring removes boilerplate code (52% AST node reduction) - second refactoring makes loop semantics explicit LambdaFicator saves programmer effort - contains a copy-paste error: number in row 9 is copied from 8 - first refactoring changed avg. of 412 SLOC/project in 11 seconds - second refactoring changed avg. of 1368 SLOC/project in 11 seconds The number of spreadsheet end-users is at least 100M => 10x more errors than in professional programs 13 14 Spreadsheets that are changing are Our Refactorings prone to errors We studied a corpus of 3,700 real world spreadsheets 1. Replace Awkward Formula Spreadsheets are riddled with problems: 2. Extract Literal - decreasing maintainability (e.g., duplicated expressions) 3. Guard Call - decreasing performance (e.g., redundant computation) 4. String to Dropdown 5. Introduce Cell Name End-users have to maintain spreadsheets 6. Make Cell Constant - life-span: 5 years, end-users/sheet: 13 [Hermans – ICSE’11] 7. Extract Column Smells mask errors that cost [Burnett – CACM’04] - TransAlta lost $24M in 2003 due to cut-and-paste error in Excel Implemented in our tool, REFBOOK, world’s first interactive - The Fed made a copy-paste error in their consumer credit statement, refactoring tool for Microsoft Excel could have led to $4B loss 15 16 Extract Column Refactoring needs to change elements “similar” to the one selected Need to ensure that all expressions in the column have the “same” formula, despite not being exact matches Precondition: Extract Column Refactoring - formulas in the column of selected expression are consistent Two formulas are consistent if their ASTs are isomorphic Refactoring steps for each row: - compute the corresponding expression (e.g., B2+C2+D2+E2) 17 - insert corresponding expression in the new column - replace references to expression with the name of new cell 18 3
3-pronged Evaluation shows REFBOOK is Practical Impact of My Research useful 1. Survey Several of our tools ship with official release of 2. Controlled experiment 3. Case study Eclipse alone had 13M downloads in 2014 RQ1: Do refactorings improve spreadsheet quality? Yes, for 4 refactorings users preferred refactored sheets Influenced official concurrency libraries of Java and .NET RQ2: Can REFBOOK make the process reliable? Yes, REFBOOK safe, manual refactorings had errors Our tools used in industry RQ3: Do automated refactorings improve human productivity? Yes, 2x-20x productivity improvement Hundreds of accepted OSS patches RQ4: Are the refactorings applicable? Yes, 32% of formulas are candidates for ExtractColumn http://learnparallelism.net (120,000 visitors) 19 20 Future Work: Change-Oriented Programming Collaborators Environment • Alexandria Shearer (ugrad) • Frank Tip (U of Waterloo) • Anda Bereckzy (ugrad) • Lyle Franklin (ugrad) • Julian Dolby (TJ Watson) Enable a software revolution similar with the industrial • Alex Gyori (ugrad) • Danny Soroker (TJ Watson) • Alex Sikora (ugrad) revolution • John Marrero (ugrad) • Ramón Cáceres (TJ Watson) • Mihai Tarce (ugrad) • Jack Ma (ugrad) • Andreas Schade (TJ Watson) • Lorand Szakacs (ugrad) • Sandro Badame (MS) • Susan Spraragen (TJ Watson) Semi-automated transformations at center of software • Fredrik Kjolstadt (MS) • Alpana Tiwari (TJ Watson) • Kely Garcia (MS) development • Kashif Manzoor (MS) • Tien Nguyen (IA State) • Can Comertoglu (MS) • Caius Brindescu (PhD) • Tao Xie (NCSU) • Mihai Codoban (PhD) • Michael Hilton (PhD) • Kunal Taneja (NCSU) - View programs as a composition of transformations • Sergey Shmarkatiuk (PhD) • Brett Daniel (PhD) • John Marrero (MIT) - Enable programmers to write, script, modify, and replay • Stas Negara (PhD) • Michael Ernst (U Washington) • Cosmin Radoi (PhD) transformations • Semih Okur (PhD) • Shay Artzi (MIT) • Yu Lin (PhD) • Rob Bochinno (PhD) • Adam Kiezun (MIT) • Mohsen Vakillian (PhD) • Stephen Heumann (PhD) • Marius Minea (UPT) • Jeff Overbey (PhD) • Iulian Neamtiu (UC Riverside) • Ralph Johnson • Darko Marinov • Bill Griswold (UCSD) • Marc Snir • Brian Bailey • Vibhu Mohindra (ACL Wireless) • Vikram Adve • Sarita Adve • Jan Lahoda (Oracle) 21 22 4
Recommend
More recommend