Skip to content

Your first program

After installing L and its build prerequisites, save the following program as main.l in a new directory. You do not need the compiler's source checkout.

demo/basic/main.l
Use IO's Print from `io` as "Print".
"message" is `Hello World!`.
Create "Hello" as a New Basic App.
The App Prints message.
Execute Hello.
Show Hello's Output.

Complete program. Source: demo/basic/main.l.

Example evidence

Canonical Hello World App with explicit IO.Print import and finalized output. existing-witness-not-run. Evidence guide.

Use IO's Print from `io` as "Print" imports a printing action. Backticks delimit Text; double quotes introduce names. Here, message names Text and Hello names an App.

New Basic App creates the App. The App refers to Hello, and Prints is a form of Print that puts the action in its body. See word forms.

Execute Hello starts the App and waits for it. The possessive 's selects its captured Output; Show writes those bytes without adding a newline.

Run from the directory containing main.l:

Terminal window
l build main.l
./main

The first command builds the program and prints the executable path. The second runs it. Building alone does not execute your program.

Expected output:

Hello World!

Print supplies one trailing newline. The program exits successfully with no stderr.

Building main.l creates main and a companion directory main.apps beside it. Keep both together when moving the program. See the CLI reference for build options and published files for the layout.

Keep the Print import. Use Execute to run and wait before reading Output. Remember that Print adds a newline, so message and Hello's Output differ by that final byte. See troubleshooting for build failures.

Next, learn how values and output are represented.


Canonical source: docs/guide/first-program.md.