Skip to content
Get Started

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

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.
// IO effects work everywhere
perform IO.print("Hello, World!")
perform IO.println("With a newline")
let input = perform IO.read()
// Actor effects require the runtime
perform Actor.register("my_service")
perform Actor.link(some_actor)
// OTP effects for supervision
let sup = perform Otp.create_supervisor("my_sup", 0)

New built-in operations are registered in the StdLib registry in src/stdlib.rs in the Nulang repository; see the contributor documentation for the full walkthrough. The per-effect reference pages under this section are auto-generated from that registry.