TY - JOUR
T1 - Continuations and aspects to tame callback hell on the web
AU - Leger, Paul
AU - Fukuda, Hiroaki
AU - Figueroa, Ismael
N1 - Publisher Copyright:
© 2021, IICM. All rights reserved.
PY - 2021
Y1 - 2021
N2 - JavaScript is one of the main programming languages to develop highly rich responsive and interactive Web applications. In these kinds of applications, the use of asynchronous operations that execute callbacks is crucial. However, the dependency among nested callbacks, known as callback hell, can make it difficult to understand and maintain them, which will eventually mix concerns. Unfortunately, current solutions for JavaScript do not fully address the aforementioned issue. This paper presents Sync/cc, a JavaScript package that works on modern browsers. This package is a proof-of-concept that uses continuations and aspects that allow developers to write event handlers that need nested callbacks in a synchronous style, preventing callback hell. Unlike current solutions, Sync/cc is modular, succinct, and customizable because it does not require ad-hoc and scattered constructs, code refactoring, or adding ad-hoc implementations such as state machines. In practice, our proposal uses a) continuations to only suspend the current handler execution until the asynchronous operation is resolved, and b) aspects to apply continuations in a non-intrusive way. We test Sync/cc with a management information system that administers courses at a university in Chile.
AB - JavaScript is one of the main programming languages to develop highly rich responsive and interactive Web applications. In these kinds of applications, the use of asynchronous operations that execute callbacks is crucial. However, the dependency among nested callbacks, known as callback hell, can make it difficult to understand and maintain them, which will eventually mix concerns. Unfortunately, current solutions for JavaScript do not fully address the aforementioned issue. This paper presents Sync/cc, a JavaScript package that works on modern browsers. This package is a proof-of-concept that uses continuations and aspects that allow developers to write event handlers that need nested callbacks in a synchronous style, preventing callback hell. Unlike current solutions, Sync/cc is modular, succinct, and customizable because it does not require ad-hoc and scattered constructs, code refactoring, or adding ad-hoc implementations such as state machines. In practice, our proposal uses a) continuations to only suspend the current handler execution until the asynchronous operation is resolved, and b) aspects to apply continuations in a non-intrusive way. We test Sync/cc with a management information system that administers courses at a university in Chile.
KW - Aspect-Oriented Programming
KW - Callback Hell
KW - Continuations
KW - JavaScript
UR - http://www.scopus.com/inward/record.url?scp=85118333477&partnerID=8YFLogxK
UR - http://www.scopus.com/inward/citedby.url?scp=85118333477&partnerID=8YFLogxK
U2 - 10.3897/JUCS.72205
DO - 10.3897/JUCS.72205
M3 - Article
AN - SCOPUS:85118333477
SN - 0948-695X
VL - 27
SP - 955
EP - 978
JO - Journal of Universal Computer Science
JF - Journal of Universal Computer Science
IS - 9
ER -