Language specification
What Avin is — a natively compiled, garbage-collected application language with a small type system and a light, indentation-based syntax.
Avin is a compiled, garbage-collected application language: expression-oriented code, algebraic
data, pattern matching, first-class functions, rich immutable collections, classes and traits with
real subtyping, built-in actors and state machines, and type inference, with a deliberately small
type system. Its syntax is light and quiet: indentation marks blocks, functions are often a single name(params) = expression line, and
match reads top to bottom as a list of cases.
Avin owns its whole runtime, so its generics are reified, values stay unboxed in containers,
absence is an explicit Option, equality is typed, string is a built-in type, and failures are
values. The design choices chapter lists each choice and what it means.
Principles
- Native and fast. Whole-program compilation through LLVM; generics are monomorphized; values that need no identity are not boxed. A feature whose cost is invisible at the call site needs a reason.
- Reified types. Every type that exists at compile time exists at run time; a type test never lies.
- Nominal. A type conforms to a trait or class because it says so, never because its member names happen to match.
- Two failure channels. A failure a correct caller can meet is a value (
Result,Option); a bug is a trap. There is nonulland there are no exceptions. - Library, not compiler.
println, collections, formatting and the rest are ordinary Avin code in the standard library. The compiler knows only the built-in types and a declared set of intrinsics. - Sysl is the system layer. Avin reaches Sysl — and through Sysl, C — with bindings written in Avin. The standard library is written in Avin.
Chapters
| Chapter | Contents |
|---|---|
| The AVIN philosophy | Abstraction, Versatility, Intuition and Naturalness: the principles behind the design |
| Design choices | The choices that shape the type system, runtime and library |
| Types | Built-in types, numbers, strings, tuples, functions, Any/Nothing |
| Declarations | Names in any script, data, class, trait, object, impl, members, modules, initialization |
| Generics and inference | Reification, bounds, variance, type tests, local inference |
| Union types | Unions written in annotations: syntax, normal form, injection at a single site, match by type, ? combining errors, layout |
| Refined variants | Variants that fix their type’s arguments (IntLit(value: int) -> Expr[int]), arms that learn them, hidden type parameters, coverage of the variants possible at a type |
| Equality, identity and memory | ==, ===, hashing, display, values vs references, GC |
| Threads | Starting and joining, sharing, synchronization, the memory model |
| Actors and state machines | actor and machine declarations, typed messages and Sendable, tell and ask, supervision, lifecycle, scheduling, states and transitions |
| Errors | Result, Option, ?, traps |
| Collections | The Iterable hierarchy, arrays, literals, ranges, for |
| Sysl bindings | Calling Sysl from Avin |
| C bindings | Calling C libraries directly: prototypes checked against headers, handles, buffers, callbacks |
| Operators and control flow | Operators, blocks, if, while, match |
| Call-by-name | value: -> T parameters |
| Contextual parameters | given values and using parameters: a context carried through calls, resolved lexically and coherently, never a conformance |
| Strings and formatting | Interpolation and format specifiers |
| System library | avin.process — arguments, environment, exit; avin.io — IoError, standard input; avin.fs — files and directories; avin.time (its own chapter below); avin.math — the elementary functions on real; avin.random — seeded and platform-seeded pseudo-random numbers; the environment, commands and pipelines, Source, avin.net (TCP, URLs, HTTP) and futures’ additions |
| Dates and times | avin.time: Instant, Duration, Date, Time, DateTime, Zone, Zoned and Period; the wall and monotonic clocks, calendar and zone arithmetic, ISO 8601 text and patterns |
| Regular expressions | avin.regex: the pattern language, leftmost-first backtracking, Regex, Match and MatchIterator, replacing and splitting |
| JSON | The package dev.avinlang.json, outside the standard library: depending on it, and what import avin.json says |
| Packages | avin.hocon, dependencies, version selection, avin.sum, workspaces, avin new and avin tidy, features, members of a repository, vendoring and the standard library’s modules |
| Derivation | Library-defined derives: shapes of data types and classes, derive templates, annotations, a JSON library written with them |
| User interfaces | The ui package: syslui’s views, controls and signals and syslui-sdl’s window and frame loop, bound for Avin; drawing and tapping a tree with no window |
| Settled decisions | Every decision made so far, in one list |
The syntax is light and regular: blocks by indentation, functions as name(params) -> T, match
written after the value with -> arms, generics as [T: Bound], conformance as impl Trait for Type, and classes, objects and variance in the same style.