Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Modeling and Programming Time-Sensitive Systems Using Lingua Franca Coordination Language

A hands-on tutorial for Lingua Franca (LF), a polyglot coordination language for building deterministic, time-sensitive systems. You write ordinary C or Python code inside reactors, and LF coordinates when that code runs, locally or across multiple processes, with a well-defined model of time.

This repository contains eight short labs, each built around a small program you compile, run, and extend. Expect about 1.5 to 2 hours for the full sequence.

This tutorial will be given in person on September 8, 2026, in Rome, Italy, at the Summer School of the 29th Forum on Specification and Design Languages (FDL). More information about this tutorial session can be found at: LF Tutorial at FDL 2026 Summer School.

How to use this template repository

This repository is a template repository with tutorial materials for Lingua Franca. To use this template, on GitHub, create your own repository by following the steps below:

  • At the top right of the GitHub page, select the green button saying "Use this template".
  • In the dropdown, choose "Create a new repository".
  • Then on the next page, enter your new repository name, for example, "my-lf-tutorial".
  • Make sure to change the visibility of your repository to "Private" for the "Choose visibility" option.
  • Finally, click on the green button at the bottom right saying "Create repository".

Learning outcomes

By the end of the tutorial, you will be able to:

  • Write, compile, and run LF programs with the C or Python target.
  • Compose reactors using ports, connections, parameters, and state variables.
  • Explain tags (logical time plus microstep), logical delays, and how logical time relates to physical time during execution.
  • Predict the deterministic order of reactions and resolve causality loops.
  • Bring external events (keyboard input) into a program through physical actions.
  • Structure state-dependent behavior with modal reactors, including reset and history transitions.
  • Enforce timing requirements with deadlines and build an anytime computation that respects a time budget.
  • Turn a multi-reactor program into a federation of communicating processes.

The eight labs

Lab Theme Main concepts
1 Ready, set, react Toolchain, reactors, timers, reactions, diagrams
2 Building a reactor pipeline Ports, connections, parameters, state
3 Tags, delays, and lag Logical vs. physical time, microsteps, actions
4 Predictable ordering Determinism, reaction order, causality loops
5 Reacting to the outside world Physical actions, threads, preambles
6 Changing behavior with modes Modal reactors, reset and history transitions
7 Useful work under a time budget Deadlines, handlers, anytime computation
8 One model, multiple processes Federated execution, the RTI

The links above point at the C versions; the same labs exist under Python/src. Total guided time is about 80-100 minutes.

Choose your language path

Every lab exists in both C and Python, teaching the same LF concepts with the same exercises. Pick the language you are more comfortable with and stay on that path; you can always try the other one later.

Convention used throughout: stay in your chosen project root (C/ or Python/) and run all commands from there, for example:

cd C          # or: cd Python
lfc src/lab1/ReadySetReact.lf
bin/ReadySetReact

A few target APIs differ between C and Python (for example, how you read the current logical time). Each lab README shows the correct calls for its target, and points out the differences that matter. If you finish the labs in one language and want to try the other, the side-by-side guide in docs/c-python-differences.md maps every API the labs use from one target to the other.

Setup

This tutorial uses Lingua Franca v0.13.0. Two setup options are supported.

Setup option 1: install LF locally (macOS, Ubuntu Linux, or Windows via WSL)

  1. Install a Java 17 JDK (the LF compiler runs on Java).

  2. Install the LF command-line tools:

    curl -Ls https://install.lf-lang.org | bash -s cli

    On Windows, run this inside WSL. If you get a permission error, prefix the bash with sudo. Alternatively, download the v0.13.0 archive for your platform from the LF releases page and add its bin directory to your PATH.

  3. Install the toolchain for your language path:

    • C: a C compiler (clang or gcc) and cmake.
    • Python: Python 3.10 or newer, plus a C compiler and cmake (the Python target compiles a small support extension).
  4. Install Visual Studio Code and the official Lingua Franca extension: open the Quick Open box (Ctrl+P or Cmd+P) and enter ext install lf-lang.vscode-lingua-franca.

Setup option 2: use the instructor-provided virtual machine

If local installation is not working out, use the Ubuntu VM image that the instructor distributes (ask the instructor for the imag download link):

  • On macOS, open the image with UTM.
  • On Windows, open the image with VirtualBox.

The VM has LF v0.13.0, VS Code, the LF extension, and both target toolchains preinstalled.

Readiness checklist

Run these from a terminal. Each should succeed before you start Lab 1.

lfc --version          # expect: lfc 0.13.0
java -version          # expect: version 17 or newer
code --version         # VS Code is installed

C path only:

cc --version           # or: gcc --version
cmake --version

Python path only:

python3 --version      # expect: 3.10 or newer
cmake --version

Finally, get this repository onto your machine. Create your own repository from this template on GitHub (Use this template > Create a new repository), enter your repository name, choose the visibility Private, click on Create repository, then clone it, or simply download and unpack the source. Then open the repository folder in VS Code.

Troubleshooting

  • lfc: command not found: the installer places lfc in ~/.local/bin. Add it to your PATH: export PATH=$HOME/.local/bin:$PATH (add the line to your shell profile to make it stick).
  • lfc --version reports something other than 0.13.0: you have another LF version installed earlier in your PATH. which lfc shows which one is being used.
  • Java errors from lfc: check java -version reports 17 or newer. On Ubuntu, sudo apt install openjdk-17-jdk.
  • C build errors about missing compiler or cmake: install them (xcode-select --install on macOS; sudo apt install build-essential cmake on Ubuntu/WSL).
  • Python target fails to build: make sure python3 --version is 3.10+ and that development headers are available (on Ubuntu/WSL: sudo apt install python3-dev). The generated program must be run with the same Python that was found at compile time.
  • Diagrams do not render in VS Code: make sure the Lingua Franca extension is installed and the .lf file has been saved without syntax errors; then click the diagram icon at the top right of the editor.
  • A program will not stop: interactive labs run until you quit them (q, Ctrl+D, or Ctrl+C). If a federated program is stuck, Ctrl+C in the launcher terminal stops the whole federation.

Repository layout

C/               C-target labs (work here on the C path)
  src/lab1 ... src/lab8
Python/          Python-target labs (work here on the Python path)
  src/lab1 ... src/lab8
docs/            The C/Python switching guide and shared images

When you compile, LF creates bin/, src-gen/, and (for Lab 8) fed-gen/ inside the project root. These are generated files; they are ignored by Git and safe to delete.

Questions and contact

Questions, corrections, and suggestions about this tutorial are welcome: Hokeun Kim (homepage, email: hokeun@asu.edu).

References

All labs link into the LF handbook for v0.13.0:

About

Lingua Franca tutorial template for FDL 2026 Summer School

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors