Affiliation:
1. Northeastern University, USA
Abstract
The JavaScript ecosystem provides equivalent synchronous and asynchronous Application Programming Interfaces (APIs) for many commonly used I/O operations. Synchronous APIs involve straightforward sequential control flow that makes them easy to use and understand, but their "blocking" behavior may result in poor responsiveness or performance. Asynchronous APIs impose a higher syntactic burden that relies on callbacks, promises, and higher-order functions. On the other hand, their nonblocking behavior enables applications to scale better and remain responsive while I/O requests are being processed. While it is generally understood that asynchronous APIs have better performance characteristics, many applications still rely on synchronous APIs. In this paper, we present a refactoring technique for assisting programmers with the migration from synchronous to asynchronous APIs. The technique relies on static analysis to determine where calls to synchronous API functions can be replaced with their asynchronous counterparts, relying on JavaScript's async/await feature to minimize disruption to the source code. Since the static analysis is potentially unsound, the proposed refactorings are presented as suggestions that must be reviewed and confirmed by the programmer. The technique was implemented in a tool named Desynchronizer. In an empirical evaluation on 12 subject applications containing 316 synchronous API calls, Desynchronizer identified 256 of these as candidates for refactoring. Of these candidates, 244 were transformed successfully, and only 12 resulted in behavioral changes. Further inspection of these cases revealed that the majority of these issues can be attributed to unsoundness in the call graph.
Publisher
Association for Computing Machinery (ACM)
Subject
Safety, Risk, Reliability and Quality,Software
Reference23 articles.
1. 2020. ECMAScript 2020 Language Specification. https://www.ecma-international.org/ecma-262/11.0/ 2020. ECMAScript 2020 Language Specification. https://www.ecma-international.org/ecma-262/11.0/
2. 2021. Express Web Framework for JavaScript. http://expressjs.com/ 2021. Express Web Framework for JavaScript. http://expressjs.com/
3. 2021. Jest: A delightful JavaScript Testing Framework. https://jestjs.io/ 2021. Jest: A delightful JavaScript Testing Framework. https://jestjs.io/
4. 2021. Mocha - the fun simple flexible JavaScript test framework. https://mochajs.org/ 2021. Mocha - the fun simple flexible JavaScript test framework. https://mochajs.org/
Cited by
8 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Code Coverage Criteria for Asynchronous Programs;Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering;2023-11-30
2. Increasing the Responsiveness of Web Applications by Introducing Lazy Loading;2023 38th IEEE/ACM International Conference on Automated Software Engineering (ASE);2023-09-11
3. An Automatic Transformer from Sequential to Parallel Java Code;Future Internet;2023-09-08
4. reformulator: Automated Refactoring of the N+1 Problem in Database-Backed Applications;Proceedings of the 37th IEEE/ACM International Conference on Automated Software Engineering;2022-10-10
5. On the design of an interactive automatic Python programming skills assessment system;2022 14th International Conference on Electronics, Computers and Artificial Intelligence (ECAI);2022-06-30