4 ms·
Rust's advantage is that it performs static analysis at compile time. The only reason to believe that identical static analysis can not be done without the magi
by bregma 4y ago
Rust's advantage is that it performs static analysis at compile time. The only reason to believe that identical static analysis can not be done without the magic of Rust is religious fervour.
- c-cube 4y agoThe 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.
- UncleMeat 4y agoAll static analysis is performed without executing the program. That's the definition. Whether an analyzer is runs before codegen or after is not an incredibly meaningful distinction since both can be integrated for developer environments in precisely the same way.
- the_duke 4y agoRusts advantage is that is has made language level design tradeoffs to achieve semantics that allow for this kind of static analysis. And they only just barely managed to get something usable in the beginning. Rust ergonomics have improved a lot since 1.0. The criticism here is that C(++) advocates often claim the language is fine, and static analysis is enough to fix the problems. Rust is hopefully just a stepping stone to something better, but the assumption that no new language semantics are needed is denial.