A Reflective Functional Reactive Programming Language for Small-Scale Embedded SystemsA Reflective Functional Reactive Programming Language for Small-Scale Embedded Systems A Reflective Functional Reactive Programming Language for Small-Scale Embedded Systems
Reactive systems are computational systems that continuously respond to external events. Embedded systems are typical instances of reactive systems. Functional Reactive Programming (FRP) is a programming paradigm for reactive systems based on the functional (declarative) abstractions of time-varying values and events. They provide straightforward ways to express reactive behaviors because we often employ continuously changing data over time as the sources of external events.FRP has been actively studied and recognized to be promising for various kinds of reactive systems including embedded systems. However, with a few exceptions, the majority of the FRP systems developed so far are Haskell-based, and therefore they require substantial runtime resources. Hence, it is virtually impossible to run such FRP systems on resource-constrained platforms.In my research group, we developed Emfrp, a pure-FRP language for small-scale embedded systems. The term small-scale here indicates that the target platforms of this language are not powerful enough to run conventional operating systems. An Emfrp program can be represented as a DAG whose nodes and edges respectively correspond to time-varying values and their dependencies. The DAG is constructed at compile-time and never change at runtime. Although this property guarantees the predictability of the amount of the runtime memory, it loses the flexibility of realizing adaptive behaviors at runtime.In this talk, I present a reflective extension to Emfrp and its applications. The primary purpose of introducing reflection is to provide some level of flexibility and adaptability to the runtime system of the language. The mechanism can provide a high-level and controlled access to the internal of the runtime via time-varying values. The distinctive characteristic of our approach is that the reflective operations are also reactive. As an example, I present an adaptive runtime that reduces unnecessary computation.