Hacker News new | ask | show | jobs
by guywithahat 5 days ago
I like this answer, plus we already have most of the memory features from a practical standpoint (C++ has had RAII since before Rust was a thing, and there are plenty of memory checkers out there). Perhaps the borrow checker is a future incoming feature but I think it would be a mistake to rush to add it.
1 comments

Existing static analysers already achieve some lifetime analysis, however it is hard to go beyond what they do today without annotations.

Safe C++ proposal (based on Circle compiler) was refused, and I don't believe in profiles as they are being sold, but lets see.

At this point one could probably use LLMs to generate the annotations/memory safety proofs on the fly (and then cache them) perhaps?
In one C++ file, you can call a function in a different file and the compiler doesn't know the implementation. This allows for every file to be compiled in parallel but it blocks many forms of static analysis.

The static analyzers that can follow chains like this are extremely slow (think hours). You could certainly use an LLM but then it'd be even slower and the proof checking would still be a bottleneck.

Rust gets around this by adding annotations to functions in their interface, which happens before any of the code is compiled.

That doesn't work because it's global and borrow checking is quadratic (cubed maybe even, not sure).
I don't think you can give something like "quadratic", because obviously sometimes you cannot write those proofs. In those cases just give up after some time and have an error. Of course sometimes memory-safety counter examples can be found instead, then those can be reported.

We pretty much have the latter already. LLM agents writing tests, running it with ASAN and then creating issues for that.

Oops, I read "LLMs" as "LLVM" and thought it was referring to Clang's lifetime annotations, and asking why they cannot be inferred :(

Truly embarrassing.