Crossing the gap from imperative to functional programming through refactoring
Authors:
Open Access
- 18 August 2013
- conference paper
- Published by Association for Computing Machinery (ACM)
- p. 543-553
Abstract
Java 8 introduces two functional features: lambda expressions and functional operations like map or filter that apply a lambda expression over the elements of a Collection. Refactoring existing code to use these new features enables explicit but unobtrusive parallelism and makes the code more succinct. However, refactoring is tedious: it requires changing many lines of code. It is also error-prone: the programmer must reason about the control-, data-flow, and side-effects. Fortunately, refactorings can be automated. We designed and implemented LambdaFicator, a tool which automates two refactorings. The first refactoring converts anonymous inner classes to lambda expressions. The second refactoring converts for loops that iterate over Collections to functional operations that use lambda expressions. Using 9 open-source projects, we have applied these two refactorings 1263 and 1709 times, respectively. The results show that LambdaFicator is useful: (i) it is widely applicable, (ii) it reduces the code bloat, (iii) it increases programmer productivity, and (iv) it is accurate.Keywords
This publication has 8 references indexed in Scilit:
- Practical static race detection for Java parallel loops2013
- How do developers use parallel libraries?2012
- Extensibility for the Masses2012
- A case study on refactoring in Haskell programs2011
- Scaling Scala at Twitter2010
- A type and effect system for deterministic parallel Java2009
- Comparative Study of Refactoring Haskell and Erlang Programs2006
- Refactoring Functional Programs2005