Standard Library

Everything available to a Zinc program: global builtins, the auto-loaded prelude, native modules (implemented in Odin), and .zn library modules (plain Zinc source).

This document describes everything available to a Zinc program without writing your own code: the global builtins (always present), the auto-loaded prelude (println, printf, …), the native modules (implemented in Odin, imported by name), and the .zn library modules (written in Zinc, imported by name).

  • Builtins and the prelude need no import — they are global.
  • Everything else is imported by name: import "strings", import "algo", etc.
  • Native modules are compiled into the interpreter. .zn modules are plain Zinc source you can read and edit — and are **also embedded directly in the interpreter binary** at compile time, so a bare zinc.exe needs no $ZINC_PATH and no on-disk stdlib/ directory to import any of them. $ZINC_PATH (or an exe-adjacent stdlib/ dir) is only an override: point it at an on-disk copy of the stdlib source when you want to edit a .zn module and have your changes picked up without recompiling the interpreter.

Conventions used throughout

Error convention. Fallible library functions follow one rule (see docs/stdlib-audit-2026-07-19.md):

  • A value-returning fallible function returns (value, err), where err is nil on success or a message string on failure. Bind both: text, err := fs.read("f.txt").
  • A void action returns the err slot alone: err := fs.write(p, s).
  • A pure predicate returns a bare bool: if fs.exists(p) { … }.

The signature notation => (string, string?) means "returns a string and an optional error"; => string? means "returns an optional error alone"; => bool is a predicate that cannot fail.

Signatures are written in Zinc syntax. ..any is variadic. T? is T | nil (optional). [T] is a list of T; [K, V] is a map from K to V.


Reference

builtinsAlways-available global functions — 15 functions, no import.
preludeAuto-loaded print/format wrappers — 11 functions, no import.

Native modules

Compiled into the interpreter. Import by name.

os nativeProcess, environment, and subprocess access. (8 functions)
fs nativeFilesystem I/O. (13 functions)
path nativePure path-string manipulation (no I/O). (5 functions)
time nativeClocks, sleeping, and RFC-3339 formatting. (8 functions)
math nativeNumeric functions and constants. (22 functions)
strings nativeString operations. (15 functions)
conv nativeParsing and value conversion. (9 functions)
json nativeJSON parse/serialize. (2 functions)
regex nativeA small backtracking engine (no PCRE). (5 functions)
encoding nativeByte-oriented text encodings over a string's raw UTF-8 bytes. (6 functions)
random nativeSeedable non-cryptographic PRNG. (9 functions)
crypto nativeHash digests + a CSPRNG. (7 functions)
csv nativeRFC-4180 CSV. (2 functions)
net nativeOffline URL toolkit only — not a network client. (3 functions)

.zn library modules

Written in Zinc under stdlib/. Import by name; read and edit the source directly.

algo .znFunctional collection utilities. (29 functions)
strings_ext .znHigher-level string helpers over the native strings module. (12 functions)
math_ext .znInteger math, number theory, and statistics over the native math module. (21 functions)
io .znHigher-level file/stream helpers over fs. (9 functions)
log .znStructured, leveled logging to stderr. (7 functions)
set .znSet operations backed by [string, bool] maps (keys are strings; use string(v) to hash arbitrary values). (13 functions)
queue .znFIFO Queue and LIFO Stack, thin wrappers over lists. (10 functions)
result .znFirst-class Result and Option wrappers, for passing errors as values instead of using multi-return. (14 functions)
strbuilder .znO(n) string assembly (vs. (6 functions)
async .znCooperative, single-threaded task scheduler (the run-to-completion core of the concurrency model). (3 functions)
testing .znMinimal test framework. (7 functions)
On this page