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.
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".
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.
| 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.
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.
- C path: work inside the C/ directory. See C/README.md.
- Python path: work inside the Python/ directory. See Python/README.md.
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/ReadySetReactA 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.
This tutorial uses Lingua Franca v0.13.0. Two setup options are supported.
-
Install a Java 17 JDK (the LF compiler runs on Java).
-
Install the LF command-line tools:
curl -Ls https://install.lf-lang.org | bash -s cliOn Windows, run this inside WSL. If you get a permission error, prefix the
bashwithsudo. Alternatively, download the v0.13.0 archive for your platform from the LF releases page and add itsbindirectory to yourPATH. -
Install the toolchain for your language path:
- C: a C compiler (
clangorgcc) andcmake. - Python: Python 3.10 or newer, plus a C compiler and
cmake(the Python target compiles a small support extension).
- C: a C compiler (
-
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.
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.
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 installedC path only:
cc --version # or: gcc --version
cmake --versionPython path only:
python3 --version # expect: 3.10 or newer
cmake --versionFinally, 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.
lfc: command not found: the installer placeslfcin~/.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 --versionreports something other than 0.13.0: you have another LF version installed earlier in your PATH.which lfcshows which one is being used.- Java errors from
lfc: checkjava -versionreports 17 or newer. On Ubuntu,sudo apt install openjdk-17-jdk. - C build errors about missing compiler or cmake: install them
(
xcode-select --installon macOS;sudo apt install build-essential cmakeon Ubuntu/WSL). - Python target fails to build: make sure
python3 --versionis 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
.lffile 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.
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, corrections, and suggestions about this tutorial are welcome: Hokeun Kim (homepage, email: hokeun@asu.edu).
All labs link into the LF handbook for v0.13.0: