Tin Language Documentation
Tin is a statically typed, compiled systems language with a clean, expression-oriented syntax. It compiles to native code via LLVM.
Table of Contents
| Document | Contents |
|---|---|
| 01 - Basics | Types, variables, echo, string interpolation, operators |
| 02 - Control Flow | if/else, for, match (struct + array patterns), where, defer, panic |
| 03 - Functions | Functions, closures, generics, pipe operator, overloading |
| 04 - Collections | Arrays, slices, ranges, destructuring |
| 05 - Structs | Structs, methods, fn init/fn deinit, generics, type aliases, tuples |
| 06 - Traits | Trait declaration, default methods, forward fields, vtable dispatch, generic traits |
| 07 - Enums & Unions | Integer enums, atom enums, tagged unions, native C unions |
| 08 - C Interop | extern, pointers, C struct interop, linker directives (//!) |
| 09 - Packages | use/export, package resolution, standard library overview |
| 10 - Reflection | Atoms, any type, typeof, traitof, fieldnames, getfield, setfield |
| 11 - Testing | test blocks, assert stdlib, tin test command |
| 12 - Macros | Simple macros (AST substitution), CTFE macros, backtick code-splice literals |
| 13 - Control Tags | #pure, #sideffect, #no_recurse, #no_thread, #allow_sideffect |
| 14 - Fibers & Channels | spawn, await, yield, await match, Channel[T], Future[T], async I/O, M:N scheduler |
Contributing
| Document | Contents |
|---|---|
| Style Guide | Code style for stdlib .tin files: spacing, comments, extern grouping, exports |
Standard Library
| Document | Contents |
|---|---|
| Collections | Generic collections: LinkedList[T], HashMap[K,V], List[T] and Map[K,V] traits |
| Encoding | Encoding/decoding: base16, base64, url, json, yaml sub-packages |
| Errors | Error type: Err alias, new, wrap, has, equals |
| Floats | IEEE 754 special values: NaN, Inf, NegInf, is_nan, is_finite |
| Hash | Hash functions: FNV-1a, MD5, SHA-1, xxHash3 |
| Measure | Monotonic clock: now_us, now_ms for benchmarking |
| Networking | io, ioutil, tcp, udp, unix - async I/O and socket types |
| Regex | PCRE regular expressions: compile, exec, find_all, replace, split |
| SIMD | Portable SIMD: vector types, splat, loadu, cmpeq, movemask, arch directives |
| Strings | String operations: replace, split, join, trim, contains, index_of, case conversion |
Quick taste
Tin compiles to native code via LLVM. Run a file with tin run file.tin,
build a binary with tin build file.tin, and run tests with tin test file.tin
(or tin test dir/ for one directory, tin test dir/... to recurse).
// Hello world echo "Hello, world!" // Fibonacci with pattern matching fn fib(n u32) u32 = where n <= 1: n where _: fib(n - 1) + fib(n - 2) echo fib(10) // Structs with methods struct person = name string age u8 fn init(this person) = echo "new person: {this.name}" fn show(this person) string = return "{this.name} is {this.age} years old" let pete = person{name: "Pete", age: 20} echo pete.show() // Traits trait named = label string forward fn name(this named) string = return this.label struct cat(named) = breed string let c = cat{label: "Whiskers", breed: "tabby"} echo c.name() // Fibers and channels use sync fn{#async} worker(id i64, ch sync::Channel[string]) = ch.send("result from fiber {id}") fn main() = let ch = sync::Channel[string].make(4) spawn worker(1, ch) spawn worker(2, ch) echo await ch.recv() // "result from fiber 1" or "2", whichever finishes first echo await ch.recv()
Get started
Prerequisites: clang and LLVM 21 or newer on PATH.
go build .
./tinThat's it. ./tin run file.tin to compile and execute, ./tin test dir/ to run
test blocks, or ./tin repl for the interactive REPL (optionally ./tin repl file.tin to preload a file's declarations).

























