Functional Reactive Programming for the Arduino
Not only does functional programming allow for strong scalability of compact, readable and effective code, but functional reactive programming is specifically designed to handle timing based events in an intuitive way. Juniper is designed to carry these advantages, as well as be lightweight enough to function viably on Arduino.
Juniper supports many features typical of functional programming languages, including algebraic data types, tuples, records, pattern matching, immutable data structures, parametric polymorphic functions, and anonymous functions (lambdas).
Some imperative programming concepts are also present in Juniper, such as for, while and do while loops, the ability to mark variables as mutable, and mutable references.
The Juniper compiler, standard library and documentation are all open sourced under the MIT License. The Juniper compiler itself is written in F#, an open source language originally developed by Microsoft Research.
Juniper will be presented at the ACM SIGPLAN International Workshop on Functional Art, Music, Modelling and Design (FARM) in Nara, Japan.
The presentation will provide a brief overview of the Juniper language along with typical Juniper design patterns. Juniper will be compared to the existing Arduino language of choice - C++. Existing Juniper projects will be demonstrated. In the spirit of the Maker Movement, there will be a “hands on” portion of the presentation, in which audience members will receive (at no cost) an Arduino compatible microcontroller and the components necessary to build a small project. By the end of the presentation, audience members will be able to construct the circuit and write the program for this project in Juniper.
The source code for the demo project can be found here: https://github.com/calebh/SoundBar.
Here are the PDF versions of the FARM presentations:
Our paper on the Juniper programming language was accepted to the ACM SIGPLAN International Workshop on Functional Art, Music, Modelling and Design (FARM)! The pre-print copy of the paper can be downloaded here: juniper_farm_preprint.pdf
This paper presents the design and implementation of Juniper: 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 ﬁt on resource-constrained devices, and enabling seamless interoperability with existing C++ libraries for these devices.