<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//TaxonX//DTD Taxonomic Treatment Publishing DTD v0 20100105//EN" "../../nlm/tax-treatment-NS0.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tp="http://www.plazi.org/taxpub" article-type="research-article" dtd-version="3.0" xml:lang="en">
  <front>
    <journal-meta>
      <journal-id journal-id-type="publisher-id">109</journal-id>
      <journal-id journal-id-type="index">urn:lsid:arphahub.com:pub:3dc5f44e-8666-58db-bc76-a455210e8891</journal-id>
      <journal-title-group>
        <journal-title xml:lang="en">JUCS - Journal of Universal Computer Science</journal-title>
        <abbrev-journal-title xml:lang="en">jucs</abbrev-journal-title>
      </journal-title-group>
      <issn pub-type="ppub">0948-695X</issn>
      <issn pub-type="epub">0948-6968</issn>
      <publisher>
        <publisher-name>Journal of Universal Computer Science</publisher-name>
      </publisher>
    </journal-meta>
    <article-meta>
      <article-id pub-id-type="doi">10.3897/jucs.72205</article-id>
      <article-id pub-id-type="publisher-id">72205</article-id>
      <article-categories>
        <subj-group subj-group-type="heading">
          <subject>Research Article</subject>
        </subj-group>
        <subj-group subj-group-type="scientific_subject">
          <subject>D.1 - PROGRAMMING TECHNIQUES</subject>
          <subject>D.3 - PROGRAMMING LANGUAGES</subject>
        </subj-group>
      </article-categories>
      <title-group>
        <article-title>Continuations and Aspects to Tame Callback Hell on the Web</article-title>
      </title-group>
      <contrib-group content-type="authors">
        <contrib contrib-type="author" corresp="yes">
          <name name-style="western">
            <surname>Leger</surname>
            <given-names>Paul</given-names>
          </name>
          <email xlink:type="simple">pleger@gmail.com</email>
          <uri content-type="orcid">https://orcid.org/0000-0003-0969-5139</uri>
          <xref ref-type="aff" rid="A1">1</xref>
        </contrib>
        <contrib contrib-type="author" corresp="no">
          <name name-style="western">
            <surname>Fukuda</surname>
            <given-names>Hiroaki</given-names>
          </name>
          <xref ref-type="aff" rid="A2">2</xref>
        </contrib>
        <contrib contrib-type="author" corresp="no">
          <name name-style="western">
            <surname>Figueroa</surname>
            <given-names>Ismael</given-names>
          </name>
          <xref ref-type="aff" rid="A3">3</xref>
        </contrib>
      </contrib-group>
      <aff id="A1">
        <label>1</label>
        <addr-line content-type="verbatim">Universidad Católica del Norte, Coquimbo, Chile</addr-line>
        <institution>Universidad Católica del Norte</institution>
        <addr-line content-type="city">Coquimbo</addr-line>
        <country>Chile</country>
      </aff>
      <aff id="A2">
        <label>2</label>
        <addr-line content-type="verbatim">Shibaura Institute of Technology, Tokyo, Japan</addr-line>
        <institution>Shibaura Institute of Technology</institution>
        <addr-line content-type="city">Tokyo</addr-line>
        <country>Japan</country>
      </aff>
      <aff id="A3">
        <label>3</label>
        <addr-line content-type="verbatim">Pragmatics Lab, Coquimbo, Chile</addr-line>
        <institution>Pragmatics Lab</institution>
        <addr-line content-type="city">Coquimbo</addr-line>
        <country>Chile</country>
      </aff>
      <author-notes>
        <fn fn-type="corresp">
          <p>Corresponding author: Paul Leger (<email xlink:type="simple">pleger@gmail.com</email>).</p>
        </fn>
        <fn fn-type="edited-by">
          <p>Academic editor: </p>
        </fn>
      </author-notes>
      <pub-date pub-type="collection">
        <year>2021</year>
      </pub-date>
      <pub-date pub-type="epub">
        <day>28</day>
        <month>09</month>
        <year>2021</year>
      </pub-date>
      <volume>27</volume>
      <issue>9</issue>
      <fpage>955</fpage>
      <lpage>978</lpage>
      <uri content-type="arpha" xlink:href="http://openbiodiv.net/AB06ABC7-121D-5A00-BC7F-C72B98561B62">AB06ABC7-121D-5A00-BC7F-C72B98561B62</uri>
      <history>
        <date date-type="received">
          <day>15</day>
          <month>12</month>
          <year>2020</year>
        </date>
        <date date-type="accepted">
          <day>20</day>
          <month>06</month>
          <year>2021</year>
        </date>
      </history>
      <permissions>
        <copyright-statement>Paul Leger, Hiroaki Fukuda, Ismael Figueroa</copyright-statement>
        <license license-type="creative-commons-attribution" xlink:href="https://creativecommons.org/licenses/by-nd/4.0/" xlink:type="simple">
          <license-p>This is an open access article distributed under the terms of the Creative Commons Attribution License (CC BY-ND 4.0). This license allows reusers to copy and distribute the material in any medium or format in unadapted form only, and only so long as attribution is given to the creator. The license allows for commercial use.</license-p>
        </license>
      </permissions>
      <abstract>
        <label>Abstract</label>
        <p>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.</p>
      </abstract>
    </article-meta>
  </front>
</article>
