TY - GEN
T1 - Layer Activation Mechanism for Asynchronous Executions in JavaScript
AU - Fukuda, Hiroaki
AU - Leger, Paul
AU - Cardozo, Nicolás
N1 - Publisher Copyright:
© 2022 ACM.
PY - 2022/6/7
Y1 - 2022/6/7
N2 - In modern software development with JavaScript, an asynchronous execution model is often adopted to prevent freezing execution triggered by the blocking operations. JavaScript is now used in various types of applications for the Web, smartphones, and server-side due to its rich ecosystem. In such applications, programmers implement several concerns that should perform different behavior according to the current identified context. Context-Oriented Programming (COP) posits layers as an abstraction to manage such concerns. With COP, programmers can implement context dependent application behavior in a layer, then (de)activate such layers when the context changes, leading to a change in the system behavior. Additionally, COP offers different scoping strategies which define when and how layers should be (de)activated. The dynamic extent of layers is one of such scoping strategies, which encapsulates the duration of a layer within a block, then deactivates the layer when the block execution ends. However, applying an asynchronous execution model breaks the semantics of dynamic extent because the result of an asynchronous execution generally returns when the caller of the asynchronous execution goes through the block. Existing work proposes a variant of the dynamic extent that activates a layer for a block and its logically-connected asynchronous operations by keeping information across them. However, that proposal only supports one of three kinds of asynchronous operations used in JavaScript (MacroTask, EventTask, and MicroTask). This paper extends on the existing work to support a layer activation mechanism with a scoping strategy that fulfills all three kinds of asynchronous operations in JavaScript. We show the benefit of our proposal through the implementation of a real world application for smartphones.
AB - In modern software development with JavaScript, an asynchronous execution model is often adopted to prevent freezing execution triggered by the blocking operations. JavaScript is now used in various types of applications for the Web, smartphones, and server-side due to its rich ecosystem. In such applications, programmers implement several concerns that should perform different behavior according to the current identified context. Context-Oriented Programming (COP) posits layers as an abstraction to manage such concerns. With COP, programmers can implement context dependent application behavior in a layer, then (de)activate such layers when the context changes, leading to a change in the system behavior. Additionally, COP offers different scoping strategies which define when and how layers should be (de)activated. The dynamic extent of layers is one of such scoping strategies, which encapsulates the duration of a layer within a block, then deactivates the layer when the block execution ends. However, applying an asynchronous execution model breaks the semantics of dynamic extent because the result of an asynchronous execution generally returns when the caller of the asynchronous execution goes through the block. Existing work proposes a variant of the dynamic extent that activates a layer for a block and its logically-connected asynchronous operations by keeping information across them. However, that proposal only supports one of three kinds of asynchronous operations used in JavaScript (MacroTask, EventTask, and MicroTask). This paper extends on the existing work to support a layer activation mechanism with a scoping strategy that fulfills all three kinds of asynchronous operations in JavaScript. We show the benefit of our proposal through the implementation of a real world application for smartphones.
KW - Context-Oriented Programming
KW - JavaScript
KW - asynchronous execution
UR - http://www.scopus.com/inward/record.url?scp=85144284225&partnerID=8YFLogxK
UR - http://www.scopus.com/inward/citedby.url?scp=85144284225&partnerID=8YFLogxK
U2 - 10.1145/3570353.3570354
DO - 10.1145/3570353.3570354
M3 - Conference contribution
AN - SCOPUS:85144284225
T3 - ACM International Conference Proceeding Series
SP - 1
EP - 8
BT - COP 2022 - Proceedings of the 14th International Workshop on Context-Oriented Programming and Advanced Modularity, Co-located with ECOOP 2022
A2 - Tanabe, Yudai
A2 - Lincke, Jens
A2 - Hirschfeld, Robert
A2 - Igarashi, Atsushi
A2 - Masuhara, Hidehiko
PB - Association for Computing Machinery
T2 - 14th International Workshop on Context-Oriented Programming and Advanced Modularity, COP 2022 - Co-located with ECOOP 2022
Y2 - 7 June 2022
ER -