Skip to content
Jennifer Programming Language

Jennifer libraries

Jennifer's standard library is split into topic-based libraries. Each is enabled explicitly with use NAME;; nothing is auto-loaded. This page catalogs every library that ships with the interpreter and links to the reference doc for each.

Looking for one specific function? See the cheatsheet - alphabetical list of every builtin with its library and a one-line description.

len is a language built-in primary, not a library function. Use it from any program with no use statement; it's polymorphic over string / list / map / bytes.

The TinyGo column reports whether the library runs in full on the constrained jennifer-tiny binary (TinyGo-built). A partial entry links to ../technical/tinygo.md for the restriction list; the default jennifer binary (standard Go) always supports the full surface.

net's "stubs only" is about the stock jennifer-tiny build, which ships no network driver - not a TinyGo limitation. A tiny build rebuilt with a network stack runs net too; see the note on net and TinyGo.

LibraryEnable withTinyGoContents
convertuse convert;fullconvert.toInt, convert.toFloat, convert.toString, convert.toBool, convert.typeOf - explicit casts; canonical-only toBool conversion
archiveuse archive;fulltar / zip containers over bytes (no fs). archive.pack/unpack with format "tar"/"zip"/"tar.gz"; bundle is a list of archive.Entry {name, data, mode, mtime}
asn1use asn1;fullASN.1 BER decode / DER encode over an opaque asn1.Value (designed like json), the byte layer under LDAP / SNMP / PKI. Walk with decode/typeOf/tagClass/tagNumber/get/asInt/asString/asOid/...; build with integer/octetString/oid/sequence/tagged/retag/encode. Hand-rolled, dependency-free.
binaryuse binary;fullbulk operations on bytes (the byte-data counterpart to strings/lists). binary.concat, slice, find, split, startsWith, endsWith - non-mutating, value-semantic; pushes per-byte loops into Go for throughput. Named binary because bytes is a reserved type keyword.
compressuse compress;fullbyte-stream compression. compress.pack/unpack for "gzip"/"zlib"/"deflate" (bytes in/out, optional "fast"/"default"/"best" level) + streaming (compress.stream/update/finalize); struct compress.Stream
crcuse crc;fullcrc.compute(b, algo) + streaming (crc.stream/update/finalize) for "crc32", "crc64"; output is big-endian bytes; struct crc.Stream
cryptouse crypto;fullsecurity primitives. Crypto-grade random crypto.randBytes/randInt; constant-time crypto.hmacEqual; key derivation crypto.hkdf (HKDF) / crypto.pbkdf2 (PBKDF2), algo "sha1"/"sha256"/"sha512". Digests and HMAC live in hash.
encodinguse encoding;fullintrospection (isAscii, lenBytes, lenRunes); binary-to-text toText/fromText for "hex", "base64", "base64-url"; character codecs encode/decode for "ascii", "iso-8859-1", "windows-1252", "ebcdic"
fsuse fs;fullfilesystem I/O. Whole-file readString/readBytes/writeString/writeBytes/appendString/appendBytes; metadata exists/isFile/isDir/stat; dir ops mkdir/mkdirAll/remove/removeAll/rename/list/walk; handles open/readLine/readChars/readBytes/writeString/writeBytes/eof/close; structs fs.Stat, fs.File
hashuse hash;fullhash.compute(b, algo) + streaming (hash.stream/update/finalize) for "md5", "sha1", "sha256"; struct hash.Stream
httpduse httpd;default onlyHTTP/1.1 server engine over net/http (TLS, HTTP/2, graceful shutdown). Pull loop: httpd.listen/accept/respond; request accessors method/path/query/header/body; serveFile/serveDir/shutdown. jennifer-tiny returns a friendly stub.
intluse intl;fullinternationalization: intl.load(lang, catalog) a map of string to string, intl.setLocale/locale, intl.tr(key[, params]) with %name% interpolation and a locale -> base-language -> default -> key fallback. Named intl (letters-only, like JS Intl), not i18n.
iouse io;fullio.printf, io.sprintf, io.readLine, io.eof, plus the format-verb mini-language
kvuse kv;fullin-process key/value store with per-key TTL (the no-server local counterpart to memcache / redis): kv.open / openFile (persisted) -> kv.Store, then set / add / get / has / delete / touch / incr / close. Shared handle (safe for spawn). Backs kvstore's in-process option.
jsonuse json;fullRFC 8259 json.encode/encodePretty/decode. Structs and map of string to V map to objects, bytes to base64, integral numbers decode to int else float. Decode yields generic values (no map-to-struct coercion).
linalguse linalg;fulllinear algebra over list of float (vectors) and list of list of float (matrices), the companion to stats: linalg.dot/distance/cross/normalize + norm/scale/add/sub (polymorphic over vector or matrix) + matmul/transpose/trace/determinant/inverse/solve/identity/zeros/shape. Direct algorithms (no gonum), pure-value; a singular / non-finite result is a catchable error.
listsuse lists;fulllists.push, pop, first, last, head, tail, reverse, sort, contains, concat, slice, shuffle, range - all return a new list
mapsuse maps;fullmaps.keys, values, has, delete, merge - all return a new map / list / bool
mathuse math;fullmath.abs, min, max, sqrt, pow, floor, ceil, round, rand, randInt, randSeed; constants math.PI, math.E
metause meta;fullmeta.VERSION, meta.BUILD - interpreter-self-identity constants
netuse net;stubs onlyTCP connect/listen/accept/readBytes/writeBytes/eof/address, UDP listenUDP/sendTo/recvFrom, DNS lookup/reverseLookup, polymorphic close/address; structs net.Conn, net.Listener, net.UDPSocket, net.Datagram. jennifer-tiny returns friendly errors; use the default jennifer binary for real net I/O.
osuse os;partialos.getEnv, os.hasFlag, os.flag, os.run, os.spawn, os.wait, os.poll, os.kill; constants os.PLATFORM, os.ARCH, os.EOL, os.DIRSEP, os.PATHSEP, os.ARGS
pathuse path;fullOS-aware filesystem path manipulation (the string layer paired with fs): path.base, dir, ext, stem, join, clean, isAbs, split. Pure string transforms, no I/O.
regexuse regex;fullregular expressions over string (RE2 syntax). regex.matches/find/findAll/replace/split/escape + regex.Match struct with positional and named captures. Implicit LRU cache for compiled patterns.
statsuse stats;fulldescriptive statistics over list of int / list of float: stats.mean/median/mode/variance/stddev/percentile/min/max/sum/correlation. Pure-value, dependency-free; variance/stddev are population.
mluse ml;fullclassical / predictive machine learning on tabular data (scikit-learn-lite): fit / predict models ml.linearRegression/ridge/kNN/naiveBayes/logisticRegression/decisionTree/randomForest/kMeans/pca + scalers, applied with ml.predict/transform; trainTestSplit/kFold; metrics accuracy/precision/recall/f1/confusionMatrix/rocAuc/rmse/mae/r2. Over stats/linalg; not a deep-learning framework.
stringsuse strings;fullstrings.upper, lower, contains, startsWith, endsWith, indexOf, trim, trimLeft, trimRight, replace, repeat, substring, split, chars, join
taskuse task;fullobserve and join task of T handles produced by spawn { ... }. task.wait, task.poll, task.discard, task.waitAll, task.waitAny, cancellation (cancel/cancelled), bounded waits (waitTimeout/waitAnyTimeout); pairs with the user-guide concurrency tour
channeluse channel;fullCSP channels between goroutines: channel.make(capacity), send (copies the value in), recv, close, select (fan-in), len, capacity. The streaming counterpart to task; a shared conduit that copies the data through it. channel is a contextual keyword
termuse term;default onlyterminal control for interactive TUIs: raw mode (term.makeRaw/restore -> term.State), term.size -> term.Size{rows, cols}, raw single-byte reads (term.readByte -> int, -1 at EOF). Over golang.org/x/term; jennifer-tiny returns a friendly stub. Output-only TUIs need only ansi + os.isTerminal.
testinguse testing;fulltest-runner primitives. testing.run/results/reset/report + testing.Result struct. Catches runtime errors, throws, and (uniquely) exit inside test bodies. Three report formats: "text", "tap", "junit". Foundation for the .j-side test framework.
serialuse serial;default only (Linux)blocking serial-port I/O with termios line config: serial.open(path, baud) / openWith(path, Options) -> serial.Port, read/write/flush/close. Linux /dev + ioctl; jennifer-tiny and non-Linux return a friendly stub.
spiuse spi;default only (Linux)SPI devices: spi.open(path) -> spi.Device, configure(dev, mode, speedHz), full-duplex transfer(dev, bytes) -> bytes, close. Linux-only; stub elsewhere.
i2cuse i2c;default only (Linux)the I2C bus: i2c.open(path, addr) -> i2c.Bus, read/write/readReg/writeReg/close. Linux-only; stub elsewhere.
gpiouse gpio;default only (Linux)GPIO over /dev/gpiochipN (GPIO v2 ioctls), pin-keyed setup/read/write/release + IN/OUT (mirrors the sysfs gpio module). Linux-only; stub elsewhere.
sqluse sql;default onlyrelational-database client over database/sql: MySQL / MariaDB + PostgreSQL (pure-Go drivers). open/query/exec/next + typed row accessors, transactions, prepared statements; placeholder-only binding. First heavyweight library dependency; jennifer-tiny stubs it.
timeuse time;fullinstant/duration arithmetic, calendar + Unix accessors, fixed-offset zones (time.zone, time.inZone, time.UTC, time.local), strftime format/parse, ISO round-trip; structs time.Time, time.Duration, time.Zone
tomluse toml;fullRFC-conformant TOML 1.0 toml.encode/encodePretty/decode. Same opaque toml.Value + read / walk / write surface as json, name for name, addressed by JSON Pointer; adds toml.asDatetime (backed by time.Time) for TOML's native date-times.
uuiduse uuid;fullRFC 9562 UUIDs. uuid.v4() (random) / uuid.v7() (time-ordered) + parse/isValid/version + constant NIL. The version is a method; draws from the crypto library's crypto-grade random source (unguessable, safe as a security token).
xmluse xml;fullXML xml.decode/encode/encodePretty over an opaque xml.Value, designed like json/toml. Element tree with ordered attributes + children + mixed text; accessors tag/text/attr/attrs/children, XPath-style get/findAll/has, and a build surface element/setAttr/setText/append.
yamluse yaml;fullYAML 1.2 yaml.decode/decodeAll/encode/encodePretty over an opaque yaml.Value, same read / walk / write surface as json/toml, addressed by JSON Pointer. Anchors / aliases / << merge keys, multi-document streams, yaml.asDatetime for timestamps; flow (compact) vs block (pretty) encode. Backed by gopkg.in/yaml.v3 (TinyGo-clean).

A quick taste:

jennifer
use io;
use math;
use meta;
use strings;

io.printf("Jennifer %s\n", meta.VERSION);
io.printf("pi is roughly %f\n", math.PI);
io.printf("math.sqrt(2) = %f\n", math.sqrt(2));
io.printf("upper: %s\n", strings.upper("hello"));
io.printf("len: %d\n", len("hello"));           # language built-in, no import

Namespace-first registration

Every library is namespaced: each name is reachable as lib.name(...) (call) or lib.NAME (constant). The library's name doubles as the namespace prefix at the use site.

Aliasing (use lib as alias;) is a rename, not an addition: after the alias the canonical name no longer resolves at call sites (it errors with a "did you mean alias?" hint). The canonical name is also freed for use as an ordinary identifier, just like Python's import foo as bar.

(core used to be auto-loaded and exposed len / JENNIFER_VERSION as bare globals via RegisterGlobal / RegisterGlobalConst. len was promoted to a language built-in keyword, version constants moved to meta, and core was deleted. The RegisterGlobal* API surface remains on Interpreter but is unused by any shipping library; it gets removed in a later cleanup pass.)

How libraries are organized

The standard library favors many small, focused libraries over a few large ones. The organizing principle, captured for future extensions:

  • Touches I/O (stdin/stdout/files/network/clock) -> io (which can later split into fs, net, time as it grows).
  • Pure value transformation across kinds -> convert.
  • Pure numeric -> math (includes the non-crypto random helpers).
  • String manipulation -> strings.
  • List manipulation -> lists.
  • Map manipulation -> maps.
  • Operating-system glue (env, args, host info) -> os.
  • Interpreter-self-identity constants (version, build, future build-time / git-sha / GC stats) -> meta.
  • Time / instants / durations -> time (formatting, parsing, and fixed-offset zones).
  • Cryptographic-style digests (MD5, SHA-1, SHA-256) -> hash. Non-cryptographic checksums (CRC-32, CRC-64) -> crc. The split keeps "transport integrity" and "content addressing" visible at the import line.
  • Crypto-grade randomness, constant-time comparison, and key derivation (HKDF, PBKDF2) -> crypto. The security primitives that need a secure source or a timing-safe operation, kept distinct from the digests in hash.
  • Byte / string introspection and character-set codecs (ASCII, ISO-8859-1, Windows-1252, EBCDIC IBM-1047) plus hex / base64 binary-to-text -> encoding (long-tail codecs parked for later).
  • Observing / joining background computations launched with spawn -> task. Concurrency itself is a language feature (the spawn keyword + task of T type); the library is just the observation surface.
  • Filesystem I/O (whole-file reads/writes, metadata, directory operations, buffered file handles) -> fs. Blocking on purpose; non-blocking use composes with spawn.
  • Network I/O (TCP + UDP sockets, DNS lookups) -> net. Blocking calls, same spawn-composition story as fs. The stock jennifer-tiny binary returns friendly "use the default jennifer" errors because it ships no network driver - a build choice, not a TinyGo limitation; a tiny build with a network stack runs net too.
  • Regular expressions over string -> regex. RE2 syntax (Go's regexp engine); implicit LRU cache. Pure string processing, no other library dependencies.
  • Test-runner primitives (name-based method dispatch, per-process result accumulator, format dispatcher for text/TAP/JUnit) -> testing. Lives here because Jennifer has no function references yet; the .j-side assertion vocabulary and CLI harness ship on top of these primitives.
  • A genuinely new topic with five or more functions / constants -> a new library. Fewer than five names fold into the most-related existing library (the non-crypto random helpers were the first case the rule caught - they live under math.rand* rather than getting their own library).
  • A single function with no clear topic -> the most-related existing library.
  • Genuinely polymorphic structural primitives that every program needs (len) -> language built-in keyword, not a library. The bar is intentionally high; len is the only one.

Naming convention

Library names look mixed at first glance - strings is plural but math is singular. The rule:

  • Plural for count nouns: when the library operates on instances of something you can have multiples of. strings, lists, maps, bytes, files.
  • Singular for mass nouns and conceptual wholes: math, meta, time, regex (planned).
  • Bare verb when the library is named for what it does, not what it touches: convert.
  • Idiomatic abbreviations are fine: os, fs, net, regex.

Three practical constraints reinforce the count/mass rule:

  1. Type keywords are reserved. string, int, float, bool, list, map, null cannot be library names because they tokenize as type tokens, not IDENTs. The plural form (strings, lists, maps) sidesteps this naturally.
  2. The rule matches Go's stdlib: strings and bytes are plural; math, io, os are singular. Since the interpreter is written in Go, the convention transfers cleanly to library author intuition.
  3. Within a library, function names are lowercase / camelCase (upper, startsWith, typeOf). Constants are uppercase (PI, E, VERSION, PLATFORM).

For implementation notes on how libraries register themselves with the interpreter (RegisterNamespaced, the use-gated lookup), see ../technical/interpreter.md > Builtins and libraries.

For canonical terminology (library vs module, function vs method, list vs array, ...), see ../glossary.md. This page uses the terms in that table.