Continuations and Aspects to Tame Callback Hell on the Web

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 ma...

Full description

Bibliographic Details
Main Authors: Paul Leger, Hiroaki Fukuda, Ismael Figueroa
Format: Article
Language:English
Published: Graz University of Technology 2021-09-01
Series:Journal of Universal Computer Science
Subjects:
Online Access:https://lib.jucs.org/article/72205/download/pdf/
_version_ 1830134950255394816
author Paul Leger
Hiroaki Fukuda
Ismael Figueroa
author_facet Paul Leger
Hiroaki Fukuda
Ismael Figueroa
author_sort Paul Leger
collection DOAJ
description 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.
first_indexed 2024-12-17T07:23:08Z
format Article
id doaj.art-00e763bef7394393a2c8f067c7d35674
institution Directory Open Access Journal
issn 0948-6968
language English
last_indexed 2024-12-17T07:23:08Z
publishDate 2021-09-01
publisher Graz University of Technology
record_format Article
series Journal of Universal Computer Science
spelling doaj.art-00e763bef7394393a2c8f067c7d356742022-12-21T21:58:42ZengGraz University of TechnologyJournal of Universal Computer Science0948-69682021-09-0127995597810.3897/jucs.7220572205Continuations and Aspects to Tame Callback Hell on the WebPaul Leger0Hiroaki Fukuda1Ismael Figueroa2Universidad Católica del NorteShibaura Institute of TechnologyPragmatics LabJavaScript 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.https://lib.jucs.org/article/72205/download/pdf/Callback HellAspect-Oriented ProgrammingContin
spellingShingle Paul Leger
Hiroaki Fukuda
Ismael Figueroa
Continuations and Aspects to Tame Callback Hell on the Web
Journal of Universal Computer Science
Callback Hell
Aspect-Oriented Programming
Contin
title Continuations and Aspects to Tame Callback Hell on the Web
title_full Continuations and Aspects to Tame Callback Hell on the Web
title_fullStr Continuations and Aspects to Tame Callback Hell on the Web
title_full_unstemmed Continuations and Aspects to Tame Callback Hell on the Web
title_short Continuations and Aspects to Tame Callback Hell on the Web
title_sort continuations and aspects to tame callback hell on the web
topic Callback Hell
Aspect-Oriented Programming
Contin
url https://lib.jucs.org/article/72205/download/pdf/
work_keys_str_mv AT paulleger continuationsandaspectstotamecallbackhellontheweb
AT hiroakifukuda continuationsandaspectstotamecallbackhellontheweb
AT ismaelfigueroa continuationsandaspectstotamecallbackhellontheweb