Skip to content

Standard Library overview

The standard library lives in the std/ directory of the repository and is written entirely in Marrow (.mw files). It does not use libc: every module sits on a small platform layer that talks to the operating system directly (Linux, macOS and Windows; x86_64, aarch64 and riscv64), so programs can be linked fully static with --nostdlib.

Every file in std/ starts with @no_main, which marks it as a library rather than a standalone program (see Modules & decorators).

@import("std/std.mw")

std.mw is an umbrella that imports the core modules (io, mem, string, text, vec, map, fmt, raw, sys, fs, env, path, dir). The larger or more specialised modules are imported on demand:

@import("std/std.mw")
@import("std/http.mw") // HTTP and HTTPS
@import("std/json.mw")
@import("std/task.mw") // async tasks

Modules import each other where they depend on one another, and importing the same file twice is always safe (see the deduplication rule on the modules page).

Module
io.mw Printing to stdout and stderr.
mem.mw Allocation, copying and arenas.
heap.mw The libc-free allocator behind alloc.
raw.mw Byte-level copy, fill and compare primitives.
string.mw C-string helpers and the growable String.
text.mw Character classes, searching, parsing and splitting.
fmt.mw Number formatting into buffers.
vec.mw Growable arrays.
map.mw Hash maps and linear maps.
sys.mw Exit, panic and assert.
os.mw Raw system calls and the platform layer entry point.
env.mw Command-line arguments and environment variables.
Module
fs.mw Reading and writing files.
dir.mw Directories: listing, creating, walking.
path.mw Path joining and splitting.
Module
math.mw Floating-point and integer math, written from scratch.
rand.mw Random numbers.
time.mw Clocks, sleeping and calendar conversion.
Module
net.mw TCP, UDP, DNS and IPv4 helpers.
http.mw HTTP/1.1 client and server, with HTTPS.
tls.mw A TLS 1.3 client.
x509.mw Certificate parsing and chain verification.
Module
hash.mw SHA-1/2, HMAC, HKDF and PBKDF2.
chacha.mw The ChaCha20-Poly1305 AEAD.
aes.mw AES-128-GCM.
x25519.mw Elliptic-curve Diffie-Hellman on Curve25519.
bigint.mw Arbitrary-precision unsigned integers.
rsa.mw RSA signature verification.
ecdsa.mw ECDSA signature verification on P-256 and P-384.
asn1.mw A DER reader.
encoding.mw Hex, Base64 and UTF-8.
Module
json.mw A JSON parser and writer.
Module
task.mw Cooperative tasks, channels and async I/O.
  • Errors are values. There are no exceptions and no Result type. Functions report failure with a null pointer, false, or a negative return value (system-call wrappers return -errno). Genuinely unrecoverable situations call panic(), which prints to stderr and exits with code 1.
  • Manual memory. Every _new function that allocates has a matching _free. Nothing allocates behind your back; the arena in mem.mw is an opt-in tool.
  • C strings. Text is *u8 ending in a zero byte unless a function takes an explicit length. Byte buffers take a pointer and a length.
  • Concrete containers. VecPtr, VecI64… exist as separate types; the language has generics but the std has not been rewritten with them yet.
  • Platform differences stay inside the platform layer. Portable modules compile unchanged for every target; calls a platform cannot support return -38 (ENOSYS).
  • Security notes. The cryptographic code is meant for verification and key agreement in TLS and similar uses. Comparisons of secrets use ct_equal; the rest of the code is variable-time.