Hacker News new | ask | show | jobs
by merelydev 2040 days ago
The author posted this on reddit [0] a few months ago:

Vale's main goal is to be as fast as C++, but much easier and safer, without sacrificing aliasing freedom. It does this by using "constraint references", which behave differently depending on the compilation mode:

    Normal Mode, for development and testing, will halt the program when we try to free an object that any constraint ref is pointing at.

    Fast Mode compiles constraint refs to raw pointers for performance on par with C++. This will be very useful for games (where performance is top priority) or sandboxed targets such as WASM.

    Resilient Mode (in v0.2) will compile constraint refs to weak refs, and only halt when we dereference a dangling pointer (like a faster ASan). This will be useful for programs that want zero unsafety.
Vale v0.2 will almost completely eliminate Normal Mode and Resilient Mode's overhead with:

    Compile-time "region" borrow checking, where one place can borrow a region as mutable, or multiple places can borrow it as immutable for zero-cost safe references. It's like Rust but region-based, or Verona but with immutable borrowing.

    Pure functions, where a function opens a new region for itself and immutably borrows the region outside, making all references into outside memory zero-cost.

    "Bump calling", where a pure function's region uses a bump allocator instead of malloc/free.
[0] https://www.reddit.com/r/ProgrammingLanguages/comments/hplj2...
2 comments

I'm thinking about code/library sharing. It's useful to know from the interface what's the requirements regarding ownership and mutability. I tend to think that code sharing would be harder in vale (although I didn't read much about it).
The author also compares and contrasts at the end of a blog post: https://vale.dev/blog/zero-cost-refs-regions#afterword:borro...