Skip to content
Try Nulang

Standard Library Overview

Nulang ships with a set of built-in effects wired directly into the VM and runtime. These effects provide core functionality — I/O, collections, strings, timing, HTTP, web serving, actor management, OTP supervision, and AI inference.

Each effect groups related operations accessed via perform Effect.operation(...):

Effect Operations Purpose
IO print, println, read, log, log_error Console input/output
Int to_string, to_float, to_hex, to_binary Integer conversions
Float to_int, to_string, sin, cos, sqrt, tan, log, exp, log2, log10, pow Float math and conversions
String to_int, to_float, length, charAt, from_char, concat, substring String operations
Array length, push, new, set, slice Immutable array operations (value semantics)
Map new, insert, get, contains, remove, size Immutable map operations
StrBuilder new, push, to_string, len, reset Efficient string building
Debug inspect Labeled value inspection
Test assert, assert_eq, assert_true Test assertions
Timer sleep Durable workflow timers
Time now Wall-clock time
Signal wait Workflow signal suspension
Random int Random integers
FS read, write, append, exists File-system access
Env get Environment variables
System arg Command-line arguments
Process run External process execution
Python import, call, get_attr Python interop
Http get, post, serve HTTP client and server
Web route, html, text, raw, redirect, serve_static, read_body, param, header, cookie, set_cookie, clear_cookie Web framework
Realtime broadcast Real-time broadcast to connected clients
Inference ask AI inference queries (canonical name; LLM.ask remains as a deprecated alias)
Actor link, unlink, monitor, demonitor, trap_exit, exit, register, unregister, whereis, set_priority Actor lifecycle management
Otp create_supervisor, supervise_child, set_template, start_child, terminate_child, child_count OTP supervision trees
Crdt increment, decrement, add, remove, set, read Replicated CRDT state

The built-in effects below are runtime/compiler primitives. Nulang also ships higher-level modules written in Nulang itself. Their canonical names, sources, stability tiers, and official package mirrors are generated from the canonical spec/stdlib/v0alpha1.json manifest.

See Standard Library Modules for the generated index.

Built-in operations are implemented in one of two places:

  • Standalone VM (ImplSite::StandaloneVm) — Operations handled by the VM directly, available in actor-free scripts (e.g., REPL, one-shot --eval).
  • Runtime Host (ImplSite::RuntimeHost) — Operations that require the actor runtime, reached through the ActorVmCallbacks trait. These are nil no-ops outside an actor context.
// Actor-only effects belong inside actor behaviors.
actor Service {
behavior connect(peer) {
perform Actor.register("my_service")
perform Actor.link(peer)
}
}
actor Peer {
behavior ping() { unit }
}
fn main() {
perform IO.print("Hello, World!")
perform IO.println("With a newline")
let service = spawn Service {}
let peer = spawn Peer {}
service ! connect(peer)
// OTP supervision is provided by the runtime host.
let sup = perform Otp.create_supervisor("my_sup", 0)
0
}

New built-in operations are registered in the StdLib registry in src/stdlib.rs. Nulang-authored module metadata belongs in spec/stdlib/v0alpha1.json; run python3 scripts/generate_stdlib.py after changing it. CI rejects stale generated module metadata and package mirrors. Per-effect reference pages remain auto-generated from the executable StdLib registry.