2017 · 12 citations · 26 references
ComputingComputer ScienceFault ToleranceFault-tolerant SystemsSystems ProgrammingError HandlingSoftware Fault ToleranceAsynchronous ProgrammingJavascript Event HandlingNon-blocking CallsRefactoring
JavaScript is a widely used programming language that makes extensive use of asynchronous computation, particularly in the form of asynchronous callbacks. These callbacks are used to handle tasks, from GUI events to network messages, in a non-blocking fashion. Asynchronous callbacks present developers with two challenges. First, JavaScript's try/catch error-handling mechanism is not sufficient for proper error handling in asynchronous contexts. In response, the JavaScript community has come to rely on the error-first protocol, an informal programming idiom that is not enforced or checked by the runtime. Second, JavaScript callbacks are frequently nested, making them difficult to handle (also known as callback hell). Fortunately, a recent language extension called promises provides an alternative to asynchronous callbacks. The adoption of promises, however, has been slow as refactoring existing code to use promises is a complex task. We present a set of program analysis techniques to detect instances of asynchronous callbacks and to refactor such callbacks, including callbacks with the error-first protocol, into promises. We implement our techniques in a tool called PROMISESLAND. We perform a manual analysis of four JavaScript applications to evaluate the tool's precision and recall, which are, on average, 100% and 83%, respectively. We evaluate PROMISESLAND on 21 large JavaScript applications, and find that PROMISESLAND (1) correctly refactors callbacks to promises, (2) outperforms a recent related refactoring technique, and (3) runs in under three seconds on all of our evaluation targets.
26
Why events are a bad idea (for high-concurrency servers)
Rob von Behren, Jeremy Condit · 2003 · 238 citations
JSAI: a static analysis platform for JavaScript
Vineeth Kashyap, Kyle Dewey, Ethan A. Kuefner et al. · 2014 · 157 citations
JSNOSE: Detecting JavaScript Code Smells
Amin Milani Fard, Ali Mesbah · 2013 · 139 citations
Fast and precise hybrid type inference for JavaScript
Brian Hackett, Shuyu Guo · 2012 · 131 citations
Breaking the barriers to successful refactoring
Emerson Murphy-Hill, Andrew P. Black · 2008 · 127 citations