Documentation

New here? Start with Getting started, then keep the one-page syntax reference open. Press / to search everything.

Start here

Language guide

VariablesThe four ways to declare a variable in OxigenLang, and what each says about mutability and type.Data typesIntegers, floats, strings, chars, booleans, arrays, tuples, maps, sets, bytes and None in OxigenLang.OperatorsArithmetic, comparison, logical and postfix operators in OxigenLang, and the order they bind in.Control flowDecisions with option and unless, guards with when, and loops with each and repeat in OxigenLang.FunctionsNamed and anonymous functions in OxigenLang: typed, default, optional and named parameters, closures and recursion.StructsStructs in OxigenLang: typed fields, methods with includes, inheritance, hidden fields and self.EnumsEnums in OxigenLang: unit, tuple and struct variants, discriminants, and matching on them.Pattern matchingName a condition once with pattern, then dispatch on it with choose. Pattern matching in OxigenLang.Type systemOxigenLang is dynamic by default. Add an annotation and a variable's type is locked and checked by the VM.Angle forms and errorsOxigenLang's <...> forms: type annotations, casts, Error and Value results, <guard>, <log>, <fail> and <test>.Imports and modulesImport the standard library or your own files with introduce: namespaces, selective imports and module caching.ConcurrencyRun work on every core with diverge and converge. Share-nothing tasks on real OS threads, with no locks.TestingWrite <test> blocks with expect() matchers next to your code and run them with oxigen test.Built-in functionsEvery built-in OxigenLang function, from print and len to range, type and the collection helpers.

Standard library

OverviewThe 23 modules of the OxigenLang standard library, what each is for, and how to import them.mathThe OxigenLang math module: arithmetic, rounding, trigonometry, logarithms and integer number theory.stringsThe OxigenLang strings module: splitting, joining, trimming, case conversion, searching and padding.arrayThe OxigenLang array module: map, filter, reduce, folds, searching, grouping and sorting.setsThe OxigenLang sets module: union, intersection, difference, subset tests and filtering.jsonThe OxigenLang json module: parse and serialize JSON, read and write JSON files, and query nested maps by dotted path.tomlThe OxigenLang toml module: parse and serialize TOML, read and write TOML files, and query nested tables by dotted path.regexThe OxigenLang regex module: matching, searching, capturing and replacing with regular expressions.resultThe OxigenLang result module: check, default, chain and recover Error || Value results without an option block.ioThe OxigenLang io module: whole-file reads and writes, and line input from the console.osThe OxigenLang os module: running programs, background processes, signals, environment variables, directories and facts about the machine.pathThe OxigenLang path module: build, split and inspect path strings, and check that one path is inside another.netThe OxigenLang net module: an HTTP and HTTPS client with streaming, plus TCP and UDP sockets.apiThe OxigenLang api module: an HTTP server with routing, JSON, HTML and static-file responses and a threaded accept loop.timeThe OxigenLang time module: clocks, sleeping and measuring elapsed time.datetimeThe OxigenLang datetime module: UTC calendar dates and times, formatting and parsing.randomThe OxigenLang random module: random integers, floats, booleans and picks from an array.encodingThe OxigenLang encoding module: Base64, hex and URL percent-encoding.hashThe OxigenLang hash module: SHA-256, SHA-1 and MD5 digests as lowercase hex.ansiThe OxigenLang ansi module: terminal colours, text styles and cursor control.parse_argsThe OxigenLang parse_args module: a command-line flag parser built on os.args().envThe OxigenLang env module: load key/value pairs from a .env file.testThe OxigenLang test module: the expect() assertion matchers behind oxigen test.channelThe OxigenLang channel module: pass messages between diverge tasks in order, with timeouts and closing.ffiThe OxigenLang ffi module: call C libraries by their C signatures, with structs, pointers, variadic functions and callbacks.

Embedding and internals