Heroes / Examples / 00-first

examples/gallery/00-first.hero

A minimal program that prints a number, and the first one this compiler ran.

A file with a main function is a program. This one prints a number and needs no imports, project file or enclosing class.

Run it

$ heroes run examples/gallery/00-first.hero

These files introduce the language one feature at a time. This page shows the program and not a result, because no test compares their output byte for byte yet.

The program

## First
#
# The smallest program worth compiling — the M-scalars-run acceptance input.
# Its C target, written by hand, was tools/spike/01-first.c (gone since 2026-10-25);
# in M-scalars-run the emitter's output was compared against that file by eye.

function main()
    print((2 + 3) * 4)
examples/gallery/00-first.hero, 8 lines

fingerprint sha256 a205436ed1cf · 1 file · index.json

Next: 01-points. All the examples.

Run one yourself: the four commands. Learn the language, or read the full specification in one file.