Toward automatic update from callbacks to Promises

Etienne Brodu 1 Stéphane Frénot 1 Frédéric Oblé 2
1 DICE - Data on the Internet at the Core of the Economy
Inria Grenoble - Rhône-Alpes, CITI - CITI Centre of Innovation in Telecommunications and Integration of services
Abstract : 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.
Type de document :
Communication dans un congrès
AWeS '15, Apr 2015, Bordeaux, France. 2015, Proceedings of the 1st Workshop on All-Web Real-Time Systems
Liste complète des métadonnées
Contributeur : Brodu Etienne <>
Soumis le : mardi 17 mars 2015 - 22:49:21
Dernière modification le : jeudi 7 février 2019 - 16:53:08
Document(s) archivé(s) le : lundi 17 avril 2017 - 17:10:13


Fichiers produits par l'(les) auteur(s)


  • HAL Id : hal-01132776, version 1



Etienne Brodu, Stéphane Frénot, Frédéric Oblé. Toward automatic update from callbacks to Promises. AWeS '15, Apr 2015, Bordeaux, France. 2015, Proceedings of the 1st Workshop on All-Web Real-Time Systems. 〈hal-01132776〉



Consultations de la notice


Téléchargements de fichiers