Goose: Memory-Safe Systems Language Without Runtime Overhead
Goose is a memory-safe systems language that eliminates the heap in favor of compiler-managed data stacks. Memory allocation and deallocation happen automatically when variables go out of scope, with no garbage collector, reference counting, or runtime allocator. The compiler statically determines which data stacks are needed and assigns variables to them, proving memory safety properties at compile time.
In benchmarks across sixteen test cases, Goose achieves significant performance advantages: 3.3x faster than idiomatic C++, 1.16x faster than hand-optimized C++, and 1.12x faster than best safe Rust, while using 1.9x, 1.3x, and 1.2x less memory respectively. These gains stem from its memory model that keeps data structures inline and contiguous, eliminating pointer indirection. Arrays never reallocate, so references into them remain valid indefinitely. The compiler infers safe reference lifetimes automatically, requiring no lifetime annotations or aliasing rules.
Goose achieves compact memory representation by keeping nested data inline within parent structures. A complex record with variable-size fields and arrays occupies 29 bytes with zero allocations in Goose compared to 160 bytes with allocations in C++ or 153 bytes with multiple allocations in Rust. Its enumeration system allocates only the memory each variant requires rather than space for the largest one, reducing memory usage by 4x and improving speed by 2x on relevant benchmarks. The language compiles to C, making it portable across any platform with a C compiler, and includes an embedded TinyCC backend for immediate in-process compilation.
Read the full article
Continue reading at Hacker News →This is an AI-generated summary. Read the original for the full story.