Juniper is a functional reactive programming language developed at Tufts University by Caleb Helbling and Louis Ades. This project was developed for the year long computer science senior design class. Dr. Samuel Guyer was the advisor and mentor for this project. His presentation in 2015 served as the starting point for this project:
Juniper is a functional reactive programming language (FRP) targeting the Arduino and related microcontroller systems. Juniper provides a number of high level features, including parametric polymorphic functions, anonymous functions, automatic memory management, and immutable data structures. Also included is a standard library which offers many useful FRP signal processing functions. Juniper is translated to standard C++ and compiled with the existing Arduino development tools, allowing Juniper programs to fit on resource-constrained devices, and enabling seamless interoperability with existing C++ libraries for these devices.
A research paper on the Juniper language has been published at the ACM SIGPLAN International Workshop on Functional Art, Music, Modelling and Design (FARM) and a presentation on the work was given in September at the International Conference on Functional Programming (ICFP) in Nara, Japan. The paper and the talk are now up on the Juniper website:
http://www.juniper-lang.org/publications/juniper_farm_preprint.pdf
VideoThe paper and presentation make these key observations about the current state of Arduino programming:
- Functions that use delay() do not compose
- Combining concurrent activities with the current style of writing Arduino code requires explicit scheduling, leading to significant cognitive overhead for the programmer.
- Any reasonably sophisticated program for the Arduino consists of an ad hoc event scheduler and finite state machine(s).
- The current style of programming the Ardunio makes it difficult to decouple the timing (event scheduler) logic from the rest of the code. This quickly leads to the infamous problem of "spaghetti code."
Here's a nice quote from the paper:
In this paper we present a new language, Juniper, for programming Arduinos and similar microcontrollers. We leverage the observation that many Arduino programs are reactive: they respond to incoming signals, process those signals, and generate new output signals. Using the existing C++ environment, these programs quickly turn into “spaghetti” code that lacks modularity and is difficult to reason about. Juniper solves this problem by using functional reactive programming (FRP). In FRP, the program reacts to events by propagating values along signals or behaviors in a directed graph. Signals and behaviors can be thought of as time varying values in the program. Nodes in the directed graph represent functions which map signals to new signals. Independent parts of the signal graph can run asynchronously, providing concurrency without any additional work by the programmer. Higher-order functions, such as map, fold, and filter, provide another level of expressive power and reuse.Conclusions
The compiler and documentation are available on the Juniper website: http://www.juniper-lang.org/
Comments
Please log in or sign up to comment.