hn.today

Goose: 1.16x faster than C++ and 1.12x than safe Rust, while memory safe

github.com47 points57 comments
Screenshot of Goose: 1.16x faster than C++ and 1.12x than safe Rust, while memory safe

Goose is a memory-safe systems programming language built around a single radical idea: there is no heap. Every dynamic value lives inline on compiler-managed data stacks; growth is a pointer bump and scope exit is the only free. That design removes allocators, garbage collection, reference counting and destructors, yielding dramatic resource and speed wins on benchmarks: across sixteen tests Goose reports 3.3× idiomatic C++ speed, 1.16× hand-optimized C++, and 1.12× the best safe Rust while using less memory (summary and full results available). Nothing ever moves, so references into growing arrays remain valid, relative links can be stored in 1-4 byte offsets, and values are constructed directly in their final destination. Goose compiles to a single C file (TinyCC backend included) and interoperates with plain C.

The language enforces safety without lifetime annotations by inferring a static root for every reference and rejecting only outliving the owner. Its array and string family is “flat all the way down”: variable-size fields sit inline, arrays can be fixed, frozen, capacity-inline, grow-only, or builders, and a record with variable parts can be a single contiguous block (example: an Order becomes 29 bytes with zero allocations). Algebraic data types support fixed and variable storage modes so a variant can occupy exactly its payload size. Other notable features include zero-overhead generics via untyped parameters, statically checked multi-frame error returns, and threads that share nothing (workers are separate programs passing flat values by memcpy).

Read on github.com57 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Code Scans

Code Scans

Devin introduces Code Scans, a tool that helps teams identify and implement codebase improvements based on engineering goals. It uses parallel investigation and automates pull requests, saving time and enhancing software quality. (devin.ai)

Bend

Bend

Bend is a high-speed programming language that emphasizes correctness through proofs and laws, ensuring AI-generated code is error-free. It compiles to native code, runs parallel across multiple cores or GPUs, and verifies AI adherence to rules with rapid type checking and proof systems. (bend-lang.com)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.