← Catalog

RFC-007AcceptedRuntime

Standard Library

Depends: RFC-001RFC-002RFC-003RFC-006

Blocks: RFC-011

1. Abstract

This RFC outlines the Aura standard library for servers and CLIs: prelude, collections, I/O, networking primitives, JSON, logging, synchronization, crypto baseline, testing support types, and FFI helpers. It is core-only—no HTTP application framework, ORM, or DI container.

Implementation is primarily Aura, with thin runtime/FFI bridges where required.

Toolchain today (2026-07-21, C12r): repo packages std/io (console + file: print/println/eprint/eprintln, readFile/tryReadFile/writeFile/appendFile/fileExists/fileSize; process: args/readLine/readAllStdin/exit), std/assert (assert), and std/collections (Map/Set/HashMap String→Int / HashMapStr String→String / Iterable + Int·String HOF + join). Package builds auto-prelude std.io and resolve std.* path deps. Strict file I/O throws String on error; tryReadFile returns String? (C12p). Full Result wrappers deferred. No net/json/async I/O yet.

2. Motivation

2.1 Problem statement

A language without a solid stdlib cannot bootstrap an ecosystem. Conversely, a stdlib that includes full web frameworks freezes opinions and bloats core.

2.2 Why now

Compiler MVP needs types to lower; users need I/O and collections for non-toy programs.

2.3 Success metrics

MetricTarget
CoverageBuild CLI + TCP service with std only
CohesionConsistent error (Result/Error) and null styles
SizeTree-shaken / linked only used parts as feasible

3. Goals

  • Batteries for collections, text, time, I/O, net primitives, JSON, log, sync, crypto basics.
  • Async-friendly APIs matching RFC-003.
  • Stable naming and package layout under std.*.
  • Safe defaults; unsafe isolated.

4. Non-goals

  • HTTP router/framework, GraphQL, gRPC codegen (ecosystem).
  • Database drivers / ORM.
  • GUI, mobile, browser DOM.
  • Full TLS policy engine beyond practical client/server primitives (detail open).

5. Prior art & alternatives

LibraryNotesTake
Go stdlibPragmatic net/ioInspiration
Java stdlibLargeAvoid bloat
Rust std + cratesLayeredSplit core vs ecosystem
Kotlin stdlibCollections DXInspiration

6. Design

6.1 Package map (v1)

PackageContents
std.preludeAuto-imported essentials: String methods surface, Result, Option/T? helpers, println maybe re-export
std.coreAny, Error, primitives wrappers if any
std.collectionsList, Map, Set, Vec/ArrayList, iterators
std.str / string opsUnicode-aware helpers
std.ioReader/Writer, files, stdin/stdout
std.fsPath, metadata, directory
std.netTCP/UDP/Unix sockets; not full HTTP server framework
std.httpDeferred as full client/server; ecosystem packages first. Net primitives stay in std.net
std.jsonParse/serialize
std.logStructured levels
std.syncMutex, RwLock, Channel, Atomic, Once
std.taskspawn, scope, sleep (thin over runtime)
std.timeInstant, Duration, clock
std.cryptoHash (SHA-2), HMAC, random; TLS via well-scoped API
std.encodingBase64, hex, UTF-8
std.ffiC string/buffer helpers
std.reflectOpt-in reflection (RFC-009)
std.testAssert helpers (RFC-011)

6.2 Error conventions

  • Expected failures: Result<T, E> with typed errors (IoError, ParseError).
  • Abnormal: throw hierarchy under Error.
  • I/O: prefer Result for recoverable IO.

6.3 Collections sketch

aura
let xs = List.of(1, 2, 3)
let ys = xs.map((x) => x * 2)
var m = Map<String, Int>()
m.put("a", 1)
  • Generics monomorphized per RFC-002.
  • Iteration via Iterable interface.
  • Naming: one growable List<T> in std.collections; language builtin Array<T> stays for dense buffers. No separate Vec type.

6.4 Concurrency surface

aura
val ch = Channel<Int>()
spawn { ch.send(1) }
val v = ch.receive()
Mutex.withLock(mu) { /* ... */ }

6.5 I/O & net

  • Async methods: await file.readToEnd(), await tcp.accept().
  • Blocking variants available for scripts; prefer async in servers.

6.6 JSON

aura
val user = Json.parse<User>(text)?  // or Result
val text = Json.stringify(user)
  • Uses attributes for field names (RFC-009) when available; MVP may require manual serializers.

6.7 Crypto baseline

  • Secure random, SHA-256, HMAC-SHA256.
  • Password hashing: recommend ecosystem or carefully chosen one (open).
  • TLS: client/server streams—implementation may wrap OS/backend libraries.

6.8 Versioning

  • Stdlib versioned with toolchain.
  • std is not published as a normal registry package users replace casually; ship with compiler.

6.9 Examples

aura
import std.io.println
import std.net.TcpListener
import std.task.spawn

fun main() {
  // conceptual
  println("ok")
}

6.10 Error model / edge cases

TopicPolicy
Partial UnicodeDocument UTF-8 errors
Time zonesExplicit API; avoid implicit local footguns
Cancelled IOMap to cancellation errors

6.11 Compatibility & migration

  • Deprecations via @deprecated.
  • Major toolchain bumps may remove deprecated APIs.

7. Open questions

#QuestionOptionsOwnerStatus
1Thin std.http client in v1?deferStdlibResolved — defer
2List naming: List vs VecList + growable Vec or single typeStdlibResolved — single growable List<T>; keep builtin Array<T>; no Vec
3Password hash in std?noStdlibResolved — ecosystem
4Prelude sizesmallStdlibResolved — minimal prelude

8. Rationale & trade-offs

Go-like pragmatic breadth without framework lock-in. Async-first net matches runtime. Keeping HTTP frameworks out preserves modularity. Cost: users assemble stacks from packages early—desired for ecosystem health.

9. Unresolved / future work

  • Full API reference site
  • Capability-based FS/net permissions (sandbox)
  • SIMD / performance utilities

10. Security & safety considerations

  • Crypto APIs hard to misuse (no ECB footguns in public API).
  • TLS defaults modern.
  • Path traversal helpers safe-by-default.
  • std.ffi clearly unsafe-adjacent.

11. Implementation plan (optional)

PhaseScopeExit criteria
S0Prelude + collections + io printHello
S1fs + sync + taskConcurrent CLI
S2net + json + logTiny TCP JSON service
S3crypto baselineSecure random + hash

12. References


Changelog

DateAuthorChange
2026-07-16Lock List<T> naming; Status → Accepted
2026-07-16Status → In Review — Review: package map locked; most packages still sketch-level
2026-07-16Note shipped std.io / std.assert + Array MVP
2026-07-15Initial skeleton
2026-07-15Solid draft: package map, core-only scope
2026-07-15Defer std.http; lock small prelude, no password hash