Awesome
Juniper
Juniper is a functional reactive programming language currently being developed by Caleb Helbling (currently at Draper Laboratory). Louis Ades was a former developer at Tufts University.
The grammar in EBNF (extended Backus-Naur Form) is available in grammer.bnf. The BNF & EBNF Highlighting extension in VS Code is useful for viewing this file.
The purpose of Juniper is to provide a functional reactive programming platform for designing Arduino projects. FRP's high-level approach to timing-based events fits naturally with Arduino, with which programming almost entirely revolves around reacting to realtime events. Juniper transpiles to Arduino C++, which is then compiled to an Arduino executable.
Examples
See the examples folder located here: https://github.com/calebh/Juniper/tree/master/Juniper/examples
To see examples of pre-written C++ wrapper libraries, go to https://github.com/calebh/Juniper/tree/master/Juniper/wrappers
Language Features
- Compiler written in F#
- Transpiled to C++
- Statically typed
- Algebraic datatypes
- Use of records as datatypes (the equivalent of structs in C++)
- First class functions
- Type inference
- Use of templates to create maximum capacity length lists.
Repository Contents
juniper.sln
- Microsoft Visual F# Solution used for developing this project
grammar.bnf
- Juniper Grammar and Concrete Syntax
- This is the grammar used for our language in this repository. It is represented in Extended Backus-Naur Form (EBNF), a metasyntax language used for the planning of Juniper's concrete syntax.
Juniper Subfolder
- Contains the code used for the compiler
Building and Running the Juniper Compiler
To get started using Juniper, you'll first need to build the compiler using the source in this repository.
Using dotnet CLI
It is now quite easy to build Juniper from the terminal on any platform! Here we use the dotnet
command included with .NET.
- Install .NET 8 from Microsoft here: https://dotnet.microsoft.com/en-us/download
- Open a terminal and navigate to the directory containing the Juniper.sln file.
- Run
dotnet publish
to make a build for the platform you are currently on. - If you want to build a version to distribute to people without .NET installed, build a self contained version using
dotnet publish --self-contained true
- You can use the
-r
option to build for a different platform (essentially cross compiling). For instance to build forosx-arm64
, you could rundotnet publish -r osx-arm64 --self-contained true
For Windows machines:
For building:
- If you do not have it already, download and install Microsoft Visual Studio 2022.
- Clone this repository to your local machine.
- Open /Juniper.sln in Visual Studio.
- When the solution opens, go to the Solution Explorer and find the "References" tab underneath the "Juniper" project. Right click on "References", and select "Manage NuGet Packages." Verify that FParsec, Symbolism and QuikGraph are installed as part of your solution.
- Build the Juniper project (either in Debug mode or Build mode).
- The result should be a built .exe file called "Juniper.exe".
- (Optional) Add Juniper.exe to PATH variables so that it can be run from any directory.
For Linux machines:
Juniper is now on .NET 8! Juniper has been tested to work with Visual Studio Code, and probably works with Jetbrains Rider as well.
- Install .NET 8 and Visual Studio Code on your Linux system
- Install the Ionide extension for Visual Studio Code
- Build using Ionide
- Ensure that the
junstd/
,cppstd/
,examples/
,wrappers/
and thejuniper
Linux run script are copied to the directory containing the build.
To build for Linux on Windows for distribution:
- Enter the directory containing Juniper.sln from the terminal. Then run
dotnet publish -r linux-x64 --self-contained true
- Ensure that all the required directories and files got copied over into the built Linux folder. The folders to look for are:
junstd/
,cppstd/
,examples/
,wrappers/
and thejuniper
Linux run script. - Move the build to a Linux system for testing/packaging.
For MacOS machines:
- Follow these instructions (Option 3: Install Visual Studio for Mac) is tested, but choose the option that works best for you. The package manager is NuGet and has not been updated to paket.
- Open the Juniper solution. Check the references, and refresh them if necessary. Verify that FParsec, Symbolism and QuikGraph work. Update Nuget packages.
- Build the Juniper project.
For writing Juniper files:
You can write Juniper files in any text editor, but the Visual Studio Code text editor supports a plugin for Juniper text highlighting, which is very useful for code readability. Install Visual Studio Code, and install the juniper language package from within the editor.
For running the compiler:
- From the command line, run "Juniper.exe -s [.jun modules as arguments] -o [output file]"
- This should build your .cpp file. Compile and upload to your Arduino (with your preferred method, such as the Arduino IDE or PlatformIO).