Typing and semantics of asynchronous arrows in JavaScript
نویسندگان
چکیده
Asynchronous programs in JavaScript using callbacks and promises are di cultto write correctly. Many programs have subtle errors due to the unwantedinteraction of event handlers. To x such errors, the programmer is burdenedwith explicit registration and de-registration of event handlers. This producesfragile code which is di cult to read and maintain.Arrows, a generalization of monads, are an elegant solution to asynchronousprogram composition. In this paper, we present the semantics of an arrow-basedDSL in JavaScript which can encode asynchronous programs as a state machinewhere edge transitions are triggered by external events. To ensure that arrowsare composed correctly, we provide an optional type checker that reports errorsbefore the machine begins execution.
منابع مشابه
Inferring Types for Asynchronous Arrows in JavaScript
Asynchronous programming with callbacks in JavaScript leads to code that is difficult to understand and maintain. Arrows, a generalization of monads, are an elegant solution to asynchronous program composition. Unfortunately, improper arrow composition can cause mysterious failures with subtle sources. We present an arrows-based DSL in JavaScript which encodes semantics similar to ES6 Promises ...
متن کاملHybrid Typing of Secure Information Flow in a JavaScript-Like Language
As JavaScript is highly dynamic by nature, static information flow analyses are often too coarse to deal with the dynamic constructs of the language. To cope with this challenge, we present and prove the soundness of a new hybrid typing analysis for securing information flow in a JavaScript-like language. Our analysis combines static and dynamic typing in order to avoid rejecting programs due t...
متن کاملJavaScript as an Embedded DSL
Developing rich web applications requires mastering different environments on the client and server sides. While there is considerable choice on the server-side, the client-side is tied to JavaScript, which poses substantial software engineering challenges, such as moving or sharing pieces of code between the environments. We embed JavaScript as a DSL in Scala, using Lightweight Modular Staging...
متن کاملTowards Type Inference for JavaScript
Object-oriented scripting languages like JavaScript and Python are popular partly because of their dynamic features. These include the runtime modification of objects and classes through addition of fields or updating of methods. These features make static typing difficult and so usually dynamic typing is used. Consequently, errors such as access to non-existent members are not detected until r...
متن کاملA Certified JavaScript Interpreter
The JavaScript language was initially developed for web pages enrichment, allowing the execution of scripts by the browser. It is now pervasively used on the web, not only to add interactivity in websites or to embed contents from third-party sources, but also as a target platform for deploying applications written in other languages (such as ocaml bytecode [VB11], Hop [SGL06], or LLVM assembly...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- Sci. Comput. Program.
دوره 141-142 شماره
صفحات -
تاریخ انتشار 2017