HACKER Q&A
📣 gypsyharlot

C with a Borrow-Checker


What would be the closest thing to C with Rust's borrow-checker? Imagine a memory-safe C that would enable "fearless concurrency", but without all the constantly moving advanced features of Rust.

I looked at Zig, but it doesn't have anything like the borrow-checker.


  👤 thesuperbigfrog Accepted Answer ✓
Probably SPARK (programming language derived from Ada with advanced proof capabilities). The next release of SPARK will support pointer ownership similar to the Rust borrow checker:

https://blog.adacore.com/using-pointers-in-spark

https://arxiv.org/pdf/1710.07047.pdf

Concurrency in Ada is very easy. I haven't used SPARK enough to be familiar with its concurrency, but it looks very similar to Ada, but with added restrictions to allow for proofs:

https://docs.adacore.com/spark2014-docs/html/ug/en/source/co...


👤 zuzun
Modern C++ with smart pointers and the synchronization primitives from its standard library.

👤 eimrine
How about Lisp? It is memory-safe and has fearless concurrency and you have not told anything about garbage collector. Long time ago it has been used for system programming (Lisp machines).

PS. I was expecting a link to a website but it is just "Ask HN" topic.