Skip to content
All guides

learn

Standard library

Small on purpose. One obvious function per job. Linked automatically: no extra package. Unique names import themselves in a project.

Console: std.io

fn main() {
    println("Hello")
    println(42)
    print("same line ")
    println(true)
}

print writes values with no trailing newline. println writes the same, then a newline. Both take text, int, float, and bool. Space-join extra arguments. print_int / print_float / print_bool still work; they are just println for that type.

Files: std.fs

text = read("hello.txt")
write("hello.txt", "Hello")
exists("hello.txt")

Stream, Gfx, Hold, Grid

The 1.0 names that surprise people who came from other stacks:

  • Stream: live frames (stream, wire, say, hear, clip, shot)
  • Gfx: game canvas and sound (canvas, ink, flip, held, play) — run stdlib/examples/nova.bq
  • Hold: named columns (hold, stow, pick)
  • Grid: numeric arrays (zeros, dot, matmul)

Text, time, OS, math

std.text: len, concat, eq, byte, slice. std.time: now_ms, now_sec, sleep. std.os: getenv, args, arg. std.math: sin, pow, pi, lerp, and the rest of the scalars. Arrays are Grid.

HTTP client: std.http

get(url) to call others. To serve, go to Servers.

JSON and crypto

std.json.parse: keep JSON in files or on the wire ({ interpolates in Buraaq strings). std.crypto.sha256: real hex digest.

Database

std.db when Keel's api() is not enough. Prefer api("items", "title, body") for ordinary CRUD. See Postgres.

Collections

[1, 2, 3] and ["a", "b"] are growable lists (xs[i], xs.push, for x in xs). { "Asim": 30 } is a map (m["Asim"]). Hold is the table tool (hold / stow / pick).