Characterizing and refactoring asynchronous JavaScript callbacks
نویسنده
چکیده
Modern web applications make extensive use of JavaScript, which is now estimated to be one of the most widely used languages in the world. Callbacks are a popular language feature in JavaScript. However, they are also a source of comprehension and maintainability issues. We studied several features of callback usage across a large number of JavaScript applications and found out that over 43% of all callbackaccepting function call sites are anonymous, the majority of callbacks are nested, and more than half of all callbacks are invoked asynchronously. Promises have been introduced as an alternative to callbacks for composing complex asynchronous execution flow and as a robust mechanism for error checking in JavaScript. We use our observations of callback usage to build a developer tool that refactors asynchronous callbacks into Promises. We show that our technique and tool is broadly applicable to a wide range of JavaScript applications.
منابع مشابه
Inferring Types for Asynchronous Arrows in JavaScript
Asynchronous programming with callbacks in JavaScript leads to code that is difficult to understand and maintain. Arrows, a generalization of monads, are an elegant solution to asynchronous program composition. Unfortunately, improper arrow composition can cause mysterious failures with subtle sources. We present an arrows-based DSL in JavaScript which encodes semantics similar to ES6 Promises ...
متن کاملSemantics of Asynchronous JavaScriptTechnical report, 2017-07-26
The Node.js runtime has become a major platform for developers building cloud, mobile, or IoT applications using JavaScript. Since the JavaScript language is single threaded, Node.js programs must make use of asynchronous callbacks and event loops managed by the runtime to ensure applications remain responsive. While conceptually simple, this programming model contains numerous subtleties and b...
متن کاملTyping and semantics of asynchronous arrows in JavaScript
Asynchronous programs in JavaScript using callbacks and promises are di cultto write correctly. Many programs have subtle errors due to the unwantedinteraction of event handlers. To x such errors, the programmer is burdenedwith explicit registration and de-registration of event handlers. This producesfragile code which is di cult to read and maintain.Arrows, a generalization...
متن کاملA JavaScript Extension Providing Deterministic Temporal Semantics for the Internet of Things
This paper is about reconciling the highly asynchronous untimed interactions that prevail on the Internet with time-sensitive operations of Things in the Internet of Things (IoT). Specifically, this paper addresses a design pattern that is widely used on the Internet called asynchronous atomic callbacks (AAC). We show that it is possible and practical to endow AACs with temporal semantics that ...
متن کاملLevi - A Workflow Engine Using BPMN 2.0
• Don’t Call Us,We’ll Call You: Characterizing Callbacks in JavaScript , Keheliya Gallaba, Ali Mesbah, and Ivan Beschastnikh. In Proceedings of the ACM/IEEE International Symposium on Empirical Software Engineering andMeasurement (ESEM), 10 pages, 2015, [Best Full Paper Award] • Levi A Workflow Engine Using BPMN 2.0 , Keheliya Gallaba, Umashanthi Pavalanathan, Ishan Jayawardena, Eranda Sooriyab...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2015