𝕊𝕋𝕃ℂ++ and Tooling
Learning Objectives
- You know how to run code online or on your machine.
What is ?
Throughout this course, we will use a functional programming language called which the course authors designed during early 2025. The language is functional and minimalistic, and even supports polymorphism, which is a core programming language feature we will learn about during the course.
is based on lambda calculus1, but it also comes with primitive types like integers, booleans and characters. Although its foundations are much simpler, the syntax and general feel of resembles some modern functional programming languages, like Haskell.
Basics
Here’s a listing of supported features.
| Feature | Examples | Level |
|---|---|---|
| Value literals | 1, true, 'a' | Term |
| Term variables | x, foo, int.to_string, _ (initial letter lowercase) | Term |
| Type variables | X, Bar (initial letter uppercase) | Type |
| Types | Int, Bool, Char, String (= [Char]), Int -> Bool, (Int, Bool), Int + Bool, forall X, X | Type |
| Functions | fun x : Int, x, fun X : Type, [:X] | Term |
| Lists | [1, 2, 3:Int], [:Bool] | Term |
| Pairs | (1, true) | Term |
| Sums | inl 1 Bool, inr true Int have type Int + Bool | Term |
| Primitive operations | +, <=, ==, if b then x else y, f . g | Term |
| Definitions | f : Int -> String f = fun n : Int, int.to_string n <> "!" | Declaration |
| Type aliases | Nat : Type Nat = [Unit] | Declaration |
| Recursion | f : Int -> String f = f | Declaration |
| Syntax extensions | infixl x >=< y = x * y - y * x | Declaration |
| IO | io.readline : IO String | Term |
supports importing declarations from other modules using the
importkeyword, however the OpenCS platform does not support this, so imports are never used in the examples. Also there are no namespaces or visibility rules, so imports are quite limited right now.
For more complete examples with also list and sum operations, check the playground.
Online Playground
An online playground for is available here. The playground is not part of the course platform, but it remembers code you have written there locally in your browser.
Installing
You can find the source code for on GitHub: Aalto-OpenCS
is written in Rust and packaged using Nix and Docker. You can start the REPL with docker using the following command:
docker run --rm ghcr.io/aalto-opencs/stlcpp
Tip: Type
:helpin the REPL to see available commands.
However, if you want to start the REPL from a file, you need to mount it in Docker, or alternatively build the project from source. To mount the current directory in Docker and start the REPL from a file, use:
docker run --workdir /mnt -v $PWD:/mnt --rm ghcr.io/aalto-opencs/stlcpp example.stlc
example.stlc λ
Editor Integration
For VS Code/Codium, you can install the extension manually by downloading the .vsix file from the latest release.
To install it, open the extensions panel, click the ... (more actions) button, and select Install from VSIX to select the downloaded extension.
There is also experimental Zed editor syntax highlighting, which you can install using the Install Dev Extension option described here.