Interactive Programming of Reactive Systems

Louis Mandel, Florence Plateau
2009 Electronical Notes in Theoretical Computer Science  
ReactiveML is a synchronous reactive extension of the general purpose programming language OCaml. It allows to program reactive systems such as video games or simulators. This paper presents rmltop, the ReactiveML counterpart of the OCaml toplevel. This toplevel allows a programmer to interactively write ReactiveML programs which are type-checked, compiled and loaded on the fly. The user can then progressively run concurrent processes and observe the interactions between them. The main strength
more » ... of rmltop is that all valid ReactiveML expressions are accepted in the toplevel with the same semantics as in the compiler. This allows to use the ReactiveML toplevel as a debugger. Furthermore, the interpreted code is as efficient as if it was compiled. Moreover, a toplevel interpreter being itself a reactive system, another originality of rmltop is its own implementation in ReactiveML which makes it relatively light. the running processes, execute only the next n reactions or resume the execution. Those directives are directly launched in the toplevel. Additionally, the suspension directive can be launched by processes. It allows to program an observer that decides to suspend the execution when a certain condition is verified. All these features make this execution mode a convenient tool for prototyping reactive behaviors. Contrary to sequential programs, reactive programs continuously interact with their environment. Modifying and programming the environment during the execution of the system is thus useful for testing and debugging. It can also help for teaching purposes: the interaction with the processes behaviors improves the understanding of the reactive model. The ReactiveML toplevel is also useful to study dynamic reconfiguration of reactive programs. The addition of new processes during the execution can be used as a basic element to build a framework for programming reconfigurable applications. Icobjs [5,10], a graphical programming language based on the reactive model, is an example of such a framework. rmltop is included in the distribution of ReactiveML which is available at: http://rml.inria.fr. Any ReactiveML program accepted by the compiler can be executed in the toplevel. Moreover, the execution is as efficient as the compiled version of the program. The ReactiveML toplevel does not interpret programs. It compiles them into bytecode and executes the bytecode. The implementation of rmltop reuses the ReactiveML compiler. It has two consequences: (1) the implementation is small (about 500 source lines of code) and (2) the semantics of the two execution modes (the compiled mode and the interactive mode) are the same by construction. Moreover, a toplevel interpreter being itself a reactive system, one originality of rmltop is to be itself implemented in ReactiveML, making its implementation relatively elegant. The ReactiveML toplevel is based on the original idea of Reactive Scripts [8] by Frédéric Boussinot and Laurent Hazard. Reactive Scripts is a scripting language first built on ReactiveC [6] and Tcl-Tk. Then Jean-Ferdy Susini proposed a new implementation [18] of this language based on Sugar-Cubes [9] and Java. We will discuss the differences between our approach and Reactive Scripts in Section 4.1. In the following, we first present the use of rmltop in Section 2 through a collection of examples. Section 3 describes its implementation. Section 4 is devoted to a discussion and we conclude in Section 5. Interactive Programming in ReactiveML ReactiveML is an extension of OCaml 3 such that we can define data types and functions like in OCaml. Moreover, it provides synchronous reactive processes as functions that can be executed through several instants.
doi:10.1016/j.entcs.2008.01.004 fatcat:fzmng74ysfcd5jnmu2mjqubrdy