HeadlinesBriefing HeadlinesBriefing.com

Goose Language: Faster Than C++ and Rust

Hacker News •
×

Goose is a memory-safe systems language with no heap allocator, garbage collector, or lifetime annotations. Its benchmarks show it running faster than C++ and Rust while using less memory. The language features syntax familiar to C and Rust programmers, but with no heap. Every dynamic value lives inline on a data stack managed by the compiler. Growth advances a pointer, and memory is freed when its scope ends. The type and lifetime rules make this memory model safe.

Over sixteen benchmarks, Goose runs at 3.3x the speed of idiomatic C++, 1.16x hand-optimized C++ and 1.12x the best safe Rust, on 1.9x, 1.3x and 1.2x less memory. These gains come from Goose's data layouts and memory model. No allocator, no GC, no reference counting, no destructors. Memory is a handful of data stacks that the compiler assigns statically. Freeing a million-element structure is one store, however deeply it nests.

Memory safe with zero annotations. No lifetime syntax, no aliasing or exclusivity rules, no unsafe. The compiler infers what every reference is rooted in and rejects references that could outlive their owners. Nested data stays inline. A record that is 160 bytes and an allocation in C++ is 29 bytes and none in Goose.

Goose compiles to one C file, so it runs wherever a C compiler does and calls C directly through extern fn. The bundled Tiny CC backend compiles and runs a program in-process, with no build step. The tutorial walks through all of this by example, the reference covers the whole language topic by topic, and the benchmarks have the numbers, losses included.

Source: Hacker News · Summarized by HeadlinesBriefing