The Scaly Programming Language

Appendix B

Standard Library and Packages

The Standard Library

The standard library is the package scaly. Every program sees all of it without a use — it is the prelude — unless it is compiled with --no-prelude. Its modules:

scaly.memory

The region runtime: pages, regions, the frame pages the compiler gives every routine that allocates, and the traps a program raises on a bounds violation, a null unwrap or a lack of memory.

scaly.containers

String and StringBuilder; Slice[T], the borrowed view that never owns; Vector[T] of a fixed length, Array[T] that grows, List[T]; HashMap[K, V] and HashSet[T] with their builders; Option[T] (written T?) and Result[T, E]. Indexing with [] traps outside the bounds, get(i) answers an Option, and put(i, v) writes.

scaly.fiber

Fibers, the scheduler and the evented I/O beneath the operating-system module, the task pool a self-scaling for runs on, threads and channels.

scaly.os

Console, File, Directory, Path and Tcp, and the process environment.

scaly.cluster

Channels between processes over TCP: a region sent to another node moves with its whole object graph.

scaly.tensor

A tape for reverse-mode differentiation — matrix products, activations, attention, the optimizers — living in one region per tape.

scaly.operation and scaly.logic

The protocol that gives the operators their binding strength (Expressions), generated from the levels of the grammar, and and and or on bool, whose right operand is lazy.

Packages Beside It

These packages come with the toolchain. A program declares the ones it uses (package json 0.2.0, see Modules and Packages), so a program that never speaks TLS does not link OpenSSL:

http, https, h3

An HTTP/1.1 and HTTP/2 server with a router, static files, WebSocket and gRPC; the same server over TLS 1.3; and HTTP/3 over QUIC (ngtcp2).

tls

TLS 1.3 for a TCP stream, bound to OpenSSL, and the hashes and key derivations a protocol above it needs.

json

RFC 8259 JSON: a pull reader, a value tree built on it, and a writer.

compress

gzip for HTTP bodies, over libdeflate.

pg, redis, sqlite, tds

Clients of PostgreSQL (protocol version 3, SCRAM authentication, prepared statements, a pool), Redis (RESP2), SQLite (its own library) and Microsoft SQL Server (TDS 7.4).

scalygpu

A tensor tape resident on the GPU (Metal).