Juniper: A Functional Reactive Programming Language

Juniper: A Functional Reactive Programming Language © MIT

Juniper is a new functional reactive programming language for the Arduino which makes coding them significantly easier.

  • 1,714 views
  • 0 comments
  • 6 respects

Components and supplies

Apps and online services

About this project

Introduction

http://www.juniper-lang.org/

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

Video

The 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/

Code

Juniper Compiler
The source code for the Juniper compiler is available on GitHub.

Comments

Similar projects you might like

Programming ATtiny13 with Arduino Uno

by Tauno Erik

  • 10,924 views
  • 7 comments
  • 20 respects

Programming ATtiny85 with Arduino Uno

Project tutorial by Arjun Ganesan

  • 213,044 views
  • 74 comments
  • 184 respects

Graphical Programming Drawing Robot On The Wall

Project tutorial by Team KittenBot

  • 12,371 views
  • 1 comment
  • 45 respects

Programming Arduino Using Python!!!

by Smart Technology

  • 6,800 views
  • 1 comment
  • 13 respects
Add projectSign up / Login