Guide
12 chapters, from the first program to a command-line tool, for a developer who knows one other language. Each chapter builds on the ones before it. The web stack and the toolchain have their own sections: Web and Tooling.
First steps
- Getting startedInstall the compiler, write one file, run it. Vyrn needs no project file and no build step for a single program.
- Coming from another languageWhat carries over from Rust, TypeScript or Go, what is deliberately different, and what Vyrn does not have at all.
- Values and typesNumbers state their width. Text is UTF-8 bytes. A type can carry the rule that makes a value valid, and the compiler checks the rule where it can.
- Records, enums, matchA record is a shape. An enum is a choice.
matchcovers every case, and the compiler counts them.
The memory model
- Ownership, consume, regionsA parameter states what a function does with the value. The compiler enforces it and frees the memory. There is no collector, no lifetime syntax, and no borrow annotation.
- Collections and MapArrays and maps are subject-first: the value comes before the verb. A lookup answers
Option, so a missing entry is a case you handle.
Abstractions
- Protocols and genericsA protocol names methods a type can implement. A generic bounded by it is compiled once per concrete type, so dispatch costs nothing at run time.
- Function values and closuresA function is a value. Lambdas capture by reading, and every call site is resolved while the program compiles.
- Modules and importsA file is a module.
exportdecides what leaves it, and an import names what it takes.
Programs
- gen fns and generatorsA
gen fnis ordinary Vyrn that runs while the program compiles and returns Vyrn source. RPC, UI, i18n, OpenAPI and GraphQL are libraries built this way. None of them is a compiler feature. - Errors: panic, Fallible, ?There is no null and no exception. An absent value is
Option, a failure isResult, and?sends a failure to the caller unchanged. - CLI apps
args()is the argument list.std/argsreads flags and options from it, andstd/clibuilds the whole command from a record type.
Code blocks
Every code block in this documentation is a file in site/guide/: 25 programs, each run while the pages were built. The output under a block is what that program printed. The run link opens the whole source in the playground.