3 ms·
The magic of rust is that it forces all code to go through this static analysis to even compile. You can't avoid it. Even `unsafe` goes through it but with some
by c-cube 4y ago
The magic of rust is that it forces all code to go through this static analysis to even compile. You can't avoid it. Even `unsafe` goes through it but with some additional freedom. The language is designed around static analysis, for example there's syntax for lifetimes and mutable/immutable references with their lifetime.
I see no evidence that C++ (or any language) can provide the same level of confidence, without having the same sort of support in the language itself. An analysable fragment of C++ might be a thing; rust level guarantees for the whole language is very unlikely.
- gpderetta 4y agoThe proposed c++ static lifetime analysis does indeed require language kevel annotations.
- bregma 4y agoThat the language does not force you to use static analysis does not entail that it is not possible. Where I work, most C code can not be checked in to source control until the CI bot is satisfied with the static analysis run. That's necessary because of C's separate compilation model: static anaylsis requires whole-program analysis to track aliasing. Rust is a single tool that does (or may do, when opted-in) static analysis. It's not the first, not the only, and probably not the best. Other development environments use separate tools for separate operations. Engineering has always had its lumpers and dividers. Rust and Windows is for lumpers, C and Unix is for dividers.