Documentation
· hunky doryLearn the language one concept at a time. You do not need to read the specification first.
How to read this
The specification defines the language rules. It is short enough to fit in a prompt, the text you give a model. These fourteen chapters explain the language in order, one concept at a time. Consult the specification on this site when you need a precise rule.
| what | read it when |
|---|---|
| The home page, and the repository’s README | you want to know what this is and whether to look further |
| This guide, fourteen chapters | you want to learn the language one idea at a time, with programs that run |
| The specification, one file | you need the exact rule, or something did not compile and you want the sentence that refused it |
| Why, the refusals, the common questions and what is measured | you want to know why a rule is there, what was turned down, and which claims have a number behind them |
| The design document and the sittings, in the repository | you want the reasoning behind a decision, and who took it |
Every code example comes from a file in examples/. Its filename appears below the block. During the build, the process that generates the site, a check compares each block with its source and stops the build if they differ. On every commit, a change saved in the repository history, these programs are compiled and run in three configurations. Browse the examples and their output →
The chapters
Read the chapters from top to bottom: each uses concepts explained in the preceding ones. Beside each title you will find the program used for its examples.
- A first program
files, layout, comments as documentation ·
examples/gallery/00-first.hero - Errors
read a compiler message, apply its fix, and see what it does not catch ·
tests/golden/ - Records and functions
declarations, named fields, calls with a dot ·
examples/gallery/01-points.hero - Variants and match
handle every case explicitly ·
examples/gallery/02-tokens.hero - Failure is a value
no null, no exceptions ·
examples/gallery/03-fallible.hero - Control flow
if, while, for, range ·
examples/gallery/04-loops.hero - Bindings and mutation
= and @, and why shadowing is an error ·
examples/gallery/05-mutation.hero - Generics and function values
one shape, many types ·
examples/gallery/06-generics.hero - Strings
special characters, bytes and text, and a value inside a string ·
examples/gallery/07-strings.hero,12-interpolation.hero - Maps
lookup returns a value or an error ·
examples/gallery/10-maps.hero - Values all the way down
copies, and a tree with no pointer in it ·
examples/gallery/11-trees.hero - Modules and files
how to find a module and use its name ·
examples/shapes/ - Tests and holes
tests in the language, and ??? as a question ·
examples/gallery/09-holes.hero - The C boundary
extern, headers, and what clang checks for you ·
examples/gallery/08-ffi.hero