Goose: a memory-safe systems language with no heap or garbage collector
Goose is a memory-safe systems language with no heap allocator, garbage collector or lifetime annotations, and its syntax is familiar to C and Rust programmers. Across more than sixteen benchmarks in the repository, Goose runs at 3.3x the speed of idiomatic C++, 1.16x hand-optimized C++ and 1.12x the best safe Rust, while using 1.9x, 1.3x and 1.2x less memory; the published results also include cases where Goose loses. The language compiles to one C file, so it runs wherever a C compiler does and can call C directly through extern fn, and a bundled TinyCC backend compiles and runs a program in-process with no build step.
Every dynamic value lives inline on data stacks that the compiler assigns statically: a stack is a large address-space reservation with a bump pointer[1], and freeing a structure with a million elements takes a single store when its scope ends. At most one resizable value is live per stack and it is always on top, so growth never moves anything, and references into a growing array stay valid for as long as the array does. The compiler infers what every reference is rooted at and rejects references that could outlive their owners, with no lifetime syntax, no aliasing or exclusivity rules and no unsafe[2]. Nested data stays inline with no pointers — an example record that takes 160 bytes and one allocation in C++ takes 29 bytes and no allocations in Goose — and relative references store typed, checked links as 1, 2 or 4-byte offsets, so a data structure can be written to a file as is and loaded with a single read plus a verification pass. Threads have no shared memory: a worker is compiled as a separate program with its own memory, flat values cross typed queues with a memcpy, and data races, locks, atomics and memory orderings do not exist in the language.
The project ships a tutorial, a topic-by-topic reference, a specification with the exact rules and thirty-one complete sample programs. The trade-off is that an array of variable-size elements is sequential: it can be iterated but not indexed, unless a second array of references into it is kept as an index.
Read the original aardappel.github.ioDiscussion
Discussion
The language's author joined the thread to answer questions, and one commenter reported porting algorithms from a Rust codebase and finding them significantly faster in Goose. The main objection was that the C++ comparison is unfair because the example strings benefit from small string optimization[3]; commenters also asked how a fixed number of stacks can represent an arbitrary number of growable values, such as a hash table with string values, and how to handle a JSON file ranging from 1K to 1M. Others warned that without garbage collection the stacks can grow too large when old data is no longer used, compared the thread model to Dart isolates, and John Carmack praised the design, writing that parsing file and network data is often 100x slower than it needs to be.
Sources
-
aardappel.github.io
The Goose Programming Language
-
KRGeekNews KO
Goose - 힙 없이 메모리 안전성을 제공하는 시스템 프로그래밍 언어


