Goose: A Systems Language Built Around Stable, Stack-Owned Data
A growing vector is convenient until something else points inside it. Growth may move the backing allocation, so the program needs a capacity guarantee, an index in place of a reference, or a different owner for the object. This ordinary tension between growth and stable addresses drives much of the design of Goose, an experimental systems language by Wouter van Oortmerssen.
Goose makes a strong bargain. Dynamic data lives on compiler-assigned data stacks, values are assembled in their final location, and the type checker limits how references can escape. There is no general heap allocator or garbage collector in a Goose program. The result is a language where an array can grow while references to its existing elements remain valid. The cost is that programs must fit a more structured ownership model.
A stack for data, not just calls
The familiar call stack holds frames with local state. Goose also reserves large regions of virtual address space for data. Each region has a pointer to its used end. Appending a value advances that pointer; leaving the owning scope restores it. The compiler decides how many data stacks a program needs and assigns values to them. At most one resizable value is live at the top of each stack.
That last rule is the key. A growable array cannot expand into another live object because it owns the top of its stack. An append does not search for a larger block, copy elements, and update pointers. It writes at the current end and advances it. If a loop builds a million temporary records within a scope, releasing all of them can be one pointer reset. The operating system commits physical pages as needed; the reserved address range is not all resident memory.
This is more restrictive than placing arbitrary objects on a heap, but it also removes a large class of allocation and teardown work. The language reference describes the static placement rules; the program does not manually choose stack numbers.
Stable addresses change what an array can do
In C++ a std::vector reference can be invalidated by reallocation. Rust’s Vec has the same underlying possibility, and its safe API prevents keeping a mutable element borrow across a growth operation. Goose’s grow-only array, written T[>..], has a different guarantee: the storage never moves during its lifetime. A reference returned by push still refers to that element after further pushes.
That makes a single array useful as a pool of nodes. A tree can add nodes to the pool and connect them with typed references, without reserving its final capacity up front. Goose also offers reusable pools for values whose lifetimes do not nest neatly. A freed slot can be reused, though a stale reference to such a slot may then observe its new value. That is a logic bug the programmer still has to prevent, even if it cannot become a wild pointer.
Safe references rely on a second rule: each reference or slice has a root, the variable that bounds the target’s lifetime. The compiler infers that root and rejects a reference stored somewhere that could outlive it. Functions are specialized for the roots they receive. There is no lifetime annotation syntax, but there is still a lifetime discipline. A function cannot return a view into a local array that disappears at function exit.
Inline data is a layout decision
Goose’s arrays have several forms. T[k] has a fixed compile-time size; T[] has a size fixed at construction; T[..] has inline capacity; T[>..] grows at the top of a data stack. Strings are arrays of bytes, so a record can hold a variable-length string and an array of variable-length child records inline. The representation is a run of metadata and payload bytes rather than a collection of pointers to separately allocated pieces.
Consider an order with a customer name and two line items. The project’s example occupies 29 bytes in Goose, compared with 160 bytes for the cited C++ representation and 153 bytes for the cited Rust representation. Those figures describe specific layouts, not an automatic result for every record. They show the advantage of keeping the nested contents in one contiguous value: fewer allocations, less pointer chasing, and better opportunities for sequential reads.
There is a direct trade-off. If individual elements have variable sizes, the start of element n cannot always be calculated with base + n × stride. Such an array can be traversed sequentially, but random indexing requires a separate index of references. The compact layout changes which operations are cheap.
Goose makes a similar choice for tagged unions. A fixed-mode enum reserves space for its largest variant, supporting indexing and replacement. A variable-mode enum uses only the space required by each value’s actual variant. It saves room, but its array is sequential and a value cannot switch to a larger variant in place.
Links that survive a move to disk
A normal machine pointer identifies an address in one process. Goose can instead store a typed relative link as a one-, two-, or four-byte offset. The link is measured from its field or from a named pool base. Moving the whole structure preserves those relationships because the offsets do not change.
That enables a direct byte representation of a linked structure. to_bytes produces a framed image, and from_bytes verifies lengths, tags, and links before treating the input as typed data. This is more than simply casting arbitrary file bytes to a struct: validation is essential when a file may be corrupt or hostile. It also means the format inherits the language’s layout and compatibility constraints; a durable cross-version format still needs deliberate design.
Goose’s other way of avoiding movement is in-place construction. A call such as items.push(parse(line)) can build the parsed value directly inside the array’s new slot. A function returning a growable array writes into the destination supplied by its caller. This guarantee extends through nested calls, so composing builders need not create and copy an intermediate object.
Control flow and concurrency follow the same boundaries
The memory model influences features beyond containers. Goose has a checked return value from function construct that lets a parser several calls deep return an error from an active outer operation. The compiler verifies that the target call exists on every relevant path. The intermediate helpers can keep simple return types, while generated code carries the necessary signal back through those frames.
Generic functions are specialized at compile time. Function blocks such as a filter predicate are also compile-time entities rather than escaping closure objects. That makes direct calls and inlining possible, while excluding runtime function pointers and general escaping closures.
Threads use separate memory. A worker has its own data stacks and globals; it exchanges flat values through typed queues. A flat value has no references buried inside it, so it can be copied as a contiguous payload. There is no shared mutable memory in this model, and therefore no language-level data race on shared objects. The price is explicit message passing and copying instead of direct shared-state algorithms.
For native integration, Goose emits C and accepts supported C signatures through extern fn. Its bundled TinyCC path can compile and run source in the compiler process for quick iteration. A native executable goes through a C toolchain. This makes C libraries reachable, but FFI signatures must respect which Goose types have a supported C representation.
Reading the performance numbers carefully
The project’s October 16 benchmark summary reports geometric means across 16 workloads at their largest input sizes. Depending on the C backend, Goose was 3.51–3.54 times faster than the suite’s idiomatic C++ rows, 1.24–1.26 times faster than hand-tuned C++ rows, and 1.13–1.19 times faster than its best safe Rust rows. Its reported peak-memory advantages were 1.95, 1.32, and 1.25 times respectively.
Those are useful measurements of the tested implementations, not a universal ranking of languages. The suite mixes workloads where layout and allocation dominate with flat numeric kernels where Goose has little edge. The summary also selects the fastest implementation for speed and, separately, the smallest for memory; one implementation does not necessarily attain both numbers. Results come from whole-process timing on one machine, including construction and teardown. Small differences need particular caution.
The losses are informative. The calculator workload trails a Rust arena implementation; scene composition and LRU results change with the C backend. A flat blur kernel is much slower under MSVC than its row-slice form despite both being checked as free of remaining bounds checks. Removing checks alone does not force a backend to generate equally good machine code.
The strongest claim supported by these results is narrower and more interesting: for data-heavy programs that benefit from stable references and inline layout, Goose’s rules can make efficient representations natural without manual allocator management. The full tables and methodology are worth reading before carrying a ratio into another workload.
Where the model becomes awkward
Goose still asks the programmer to think about which scope owns data. Recursive functions cannot retain growable scratch data across a recursive call; longer-lived structures may need a passed-in pool. Variable-size arrays cannot provide ordinary random indexing. General function pointers, escaping closures, and shared-memory concurrency are absent. Compilation is whole-program, and the ecosystem is young.
These constraints are not side notes to an otherwise familiar language. They are what let Goose promise nonmoving growth, simple scope reclamation, and inferred safe references together. The language is most compelling when a program’s data can be built in place, traversed sequentially, and released in clear lifetime groups. It is less natural when ownership and access patterns resist those groups.
Goose is an exploration of a specific question: how much systems programming can be expressed if dynamic objects never have to wander around a heap? Its answer is a surprisingly broad set of containers, links, parsers, workers, and native interfaces. The practical test now is whether those rules remain comfortable as programs and libraries grow beyond the benchmark suite.