|
| 1 | +--- |
| 2 | +title: Runtime and Builtins |
| 3 | +description: How the current runtime story, compile workflow, and compiler-owned builtin modules fit together. |
| 4 | +--- |
| 5 | + |
| 6 | +This page explains the runtime story behind the CLI output and the `sts:*` builtin modules. |
| 7 | + |
| 8 | +## The normal workflow |
| 9 | + |
| 10 | +For most application teams, the path is simple: |
| 11 | + |
| 12 | +- author `.sts` |
| 13 | +- run `soundscript check` |
| 14 | +- use `soundscript compile` to produce deployable output |
| 15 | +- keep packaging and deployment close to how JS/TS teams already work |
| 16 | + |
| 17 | +## Compiler-owned builtin modules |
| 18 | + |
| 19 | +soundscript ships a focused builtin module surface under `sts:*`. |
| 20 | + |
| 21 | +These modules are compiler-owned. They are not regular npm packages that happen to share a prefix. |
| 22 | +That matters because the checker and compiler can reason about them directly. |
| 23 | + |
| 24 | +```ts |
| 25 | +import { normalizeThrown } from "sts:failures"; |
| 26 | +import { U8, type u8 } from "sts:numerics"; |
| 27 | +``` |
| 28 | + |
| 29 | +## The modules most app teams will notice first |
| 30 | + |
| 31 | +### `sts:prelude` |
| 32 | + |
| 33 | +Owns the small shared surface around core value-level helpers such as `Result` and `Option`. |
| 34 | + |
| 35 | +### `sts:failures` |
| 36 | + |
| 37 | +Owns `Failure`, `ErrorFrame`, and `normalizeThrown(...)` for the cases where code needs an explicit |
| 38 | +normalized error value inside the current scope. |
| 39 | + |
| 40 | +### `sts:json` |
| 41 | + |
| 42 | +Owns JSON boundary helpers so parsing and stringifying can live on an explicit soundscript surface |
| 43 | +instead of disappearing into unchecked assumptions. |
| 44 | + |
| 45 | +### `sts:numerics` |
| 46 | + |
| 47 | +Owns explicit fixed-width numeric types and helpers for the cases where host `number` semantics are |
| 48 | +too implicit. |
| 49 | + |
| 50 | +## Other builtin families |
| 51 | + |
| 52 | +The wider supported builtin surface also includes: |
| 53 | + |
| 54 | +- `sts:compare` |
| 55 | +- `sts:hash` |
| 56 | +- `sts:decode` |
| 57 | +- `sts:encode` |
| 58 | +- `sts:codec` |
| 59 | +- `sts:derive` |
| 60 | +- `sts:async` |
| 61 | +- `sts:hkt` |
| 62 | +- `sts:typeclasses` |
| 63 | + |
| 64 | +Those are real parts of the surface, but most application teams should not need all of them on day |
| 65 | +one. |
| 66 | + |
| 67 | +## Why builtins exist at all |
| 68 | + |
| 69 | +The builtin surface gives soundscript a place to define: |
| 70 | + |
| 71 | +- standard failure boundaries |
| 72 | +- standard decoding and encoding contracts |
| 73 | +- standard numeric semantics where JS host numerics are not enough |
| 74 | +- compiler-known helpers that stay consistent across tooling |
| 75 | + |
| 76 | +This is different from “invent a huge new stdlib.” The builtin surface is intentionally focused. |
| 77 | + |
| 78 | +## Builtins versus ecosystem packages |
| 79 | + |
| 80 | +soundscript does **not** require you to avoid ordinary npm packages. |
| 81 | + |
| 82 | +The model is: |
| 83 | + |
| 84 | +- use `sts:*` when you want a compiler-owned surface |
| 85 | +- use normal ecosystem packages when they solve the job |
| 86 | +- mark the boundary explicitly when `.sts` depends on regular code |
| 87 | + |
| 88 | +That keeps the language usable in existing JS/TS applications instead of turning every adoption into |
| 89 | +an ecosystem fork. |
| 90 | + |
| 91 | +## A note on Wasm-oriented features |
| 92 | + |
| 93 | +Some builtin surfaces, especially fixed-width numerics and `#[value]`, matter more if you are |
| 94 | +thinking about Wasm. The main docs path still starts with ordinary app code. |
| 95 | + |
| 96 | +## See also |
| 97 | + |
| 98 | +- [Tooling and Workflow](../guides/tooling-and-js-target.md) |
| 99 | +- [Builtin Modules](../reference/builtin-modules.md) |
| 100 | +- [Tooling and Workflow](../guides/tooling-and-js-target.md) |
0 commit comments