Reactive-C - Meije
The Reactive-C Project (March 1999)


The project started in 1988 by the design of Reactive-C which is a C based language for reactive programming. The idea was to allow a programming style close to C, in which program behaviors are defined in terms of reactions to activations.

Reactive-C

Reactive-C (RC) programs can react differently when activated for the first time, for the second time, and so on. Thus a new dimension appears for the programmer: the logical time induced by the sequence of activations. Each pair of activation/reaction is called an instant, and the reactive approach is thus an approach in which one reasons by reference to instants.

The present RC compiler is the rcc version 3 compiler. It works as a pre-processor of C, and is about 2500 lines of Ansi-C. It runs on several Unix platforms (Sun, Hp, Dec-alpha), and also on DOS/PC. It is free software.

Actually, Reactive-C appeared rapidly as being a kind of reactive assembly language that could be used to implement higher level formalisms based on the notion of an instant. We now present several formalisms implemented using RC.

Nets of Reactive Processes

The first formalism implemented in RC is called Nets of Reactive Processes (NRP). In this formalism, programs are made of reactive processes executed in parallel and communicating through unbounded fifo files called channels.

Reactive processes are sequential (that is, without parallelism) reactive programs which are able to put messages in their output channels, and to get messages from their input channels. The key point is that a process which tries to get a message from an empty channel does not remain stuck forever on that channel: reactive processes can test for channel emptyness. Because all processes share the same notion of an instant, nets of reactive processes are deterministic.

The NRP model is actually an extension of the Kahn model, introduced in 1974, by allowing processes to test channels for emptyness, while preserving determinism. The test for channel emptyness gives NRP more expressive power than Kahn's networks. For example, it becomes possible to reset a process when it receives a message on a priority channel, which was impossible in Kahn's model.

The SL Language

The SL language is a member of the family of synchronous languages in which reactions are instantaneous. Its syntax is close to esterel, but in SL hypotheses about signal presence/absence are disallowed. One decides that a signal is absent during an instant only at the end of this instant, and so reaction to the absence is delayed to the next instant.

Sources of causal circularities (the so-called causality cycles) are avoided, and the main features of the synchronous approach still remain: the expressive simplicity and power of parallelism, the ease of specification and debugging for deterministic programs, and the power and modularity of broadcast and instantaneous dialogs. However, "strong" preemptions are not possible in SL, and only "weak" ones can be used.

Forbidding immediate reactions to signal absences simplifies the implementation to a large extent (the existing implementation is less than 1000 RC lines). In addition to directly execute programs, the implementation can also be used to produce automata by symbolic evaluation.

The RLib Library

The RLib library provides primitives to program event-driven systems made of reactive agents. The basic model of RLib is called POR.

RLib is written in RC and is developed by the Soft Mountain company (which has recently became part of Versant).

Parts of the Process Control tool PROTOP/IX of Modcomp/AEG have been written in RLib. PROTOP/IX is presently used over the world, to pilot more than 20 cement factories of the Lafarge company. Rlib is also presently used in several other industrial contexts.

Reactive Objects

The Reactive Object Model (ROM) is a new formalism that merges an object approach together with the notion of a global instant. In this model, methods can be invoked using instantaneous non-blocking send orders, which are immediately processed (that is, processed during the current instant). Moreover, a method cannot execute more than once at each instant. This leads to an approach in which systems are decomposed into reactive areas where agents communicate inside their area by instantaneous orders, and between distinct areas, by usual unbounded delay orders.

The ROM model was developed under contract with the France Telecom company (contract France Telecom-CNET 93 1B 141, #506).

The semantics of the ROM model has been studied in cooperation with Cosimo Laneve from Bologna University (Italy).

A prototype language for the ROM model has been implemented in RC, as a set of macros and a library. Work on the ROM model is currently under way. We plan to design a true syntax for the present prototype language, and to study the embedding of the ROM model into a distributed framework.

Reactive Scripts

A reactive script is a program represented as a character string and intended to be run by reactive interpretors. A reactive script interpretor is a broadcast event driven interpretor which can react to several commands in parallel.

The basic principle is that absence of an event cannot be decided before the end of the current interpretor reaction. Waiting for the occurrence of an event is the basic command. Commands can be composed in several ways to build complex behaviors. Moreover, one can also define objects with associated methods which are run when a nonblocking order is sent to them. Method execution is immediate (in the same interpretor reaction as the order) and a method can be executed at most once during each reaction.

Several reactive script interpretors have been implemented in RC on top of traditional interpretors. One of these interpretors is put on top of the graphical tool Tcl/Tk.

Actually, reactive scripts are a mix of two formalisms: the SL synchronous language, and the ROM Reactive Object Model.

Reactive scripts are developed jointly with Reactive Objects, with support from the France Telecom company (contract France Telecom-CNET 93 1B 141, #506).

Icobj Programming

Icobj programming is a simple and fully graphical programming method, using a powerful means to combine behaviors. This programming is based on the notion of an icobj which has a behavioral aspect (``object'' part), a graphical aspect (``icon'' part), with an ``animation'' aspect.

Icobj programming comes from the reactive approach and provides parallelism, broadcast event communication and migration through the network.

There exists several experimental systems based on this approach, implemented with reactive scripts. WebIcobj is one of them, implemented as an applet with SugarCubes.

SugarCubes

SugarCubes is a set of Java classes for implementing software systems such as: SugarCubes is used to implement reactive scripts and icobj programming on top of the Java language.

F. Boussinot, Inria CMA/Meije, BP 93, 2004 route des Lucioles, 06902 Sophia Antipolis, France. Email: <Frederic.Boussinot@sophia.inria.fr>