Toward automatic update from callbacks to Promises - Centre of Innovation in Telecommunications and Integration of services Accéder directement au contenu
Communication Dans Un Congrès Année : 2015

Toward automatic update from callbacks to Promises

Résumé

Javascript is the prevalent scripting language for the web. It lets web pages register callbacks to react to user events. A callback is a function to be invoked later with a result currently unavailable. This pattern also proved to respond efficiently to remote requests. Javascript is currently used to implement complete web applications. However, callbacks are ill-suited to arrange a large asynchronous execution flow. Promises are a more adapted alternative. They provide a unified control over both the synchronous and asynchronous execution flows. The next version of Javascript proposes to replace callbacks with Promises. This paper brings the first step toward a compiler to help developers prepare this shift. We present an equivalence between callbacks and Dues. The latter are a simpler specification of Promises developed for the purpose of this demonstration. From this equivalence, we implement a compiler to transform an imbrication of callbacks into a chain of Dues. This equivalence is limited to Node.js-style asynchronous callbacks declared in situ. We evaluate our compiler over 64 npm packages, 9 of them present compatible callbacks and compile successfully. We consider this shift to be a first step toward the merge of concepts from the data-flow programming model into the imperative programming model.
Fichier principal
Vignette du fichier
main.pdf (290.49 Ko) Télécharger le fichier
Origine : Fichiers produits par l'(les) auteur(s)

Dates et versions

hal-01132776 , version 1 (17-03-2015)

Identifiants

  • HAL Id : hal-01132776 , version 1

Citer

Etienne Brodu, Stéphane Frénot, Frédéric Oblé. Toward automatic update from callbacks to Promises. AWeS '15, Apr 2015, Bordeaux, France. ⟨hal-01132776⟩
168 Consultations
464 Téléchargements

Partager

Gmail Facebook X LinkedIn More