4 ms·
But as the article points out, it depends on the situation. The article is right that memory safety matters a lot more in certain areas than others. The teams
by azakai 4y ago
But as the article points out, it depends on the situation. The article is right that memory safety matters a lot more in certain areas than others.
The teams you refer to are working in areas where every exploit is a huge risk, places like a browser or an OS kernel. There is a reason Rust originated among people working on a browser. What you describe is correct for them. But the article has several examples of other applications where the tradeoffs are different.
Another example: LLVM is written in C++, but that's basically fine. A memory safety exploit in clang might be annoying, but it's not a vector for taking over people's machines like a browser is. A safety exploit in clang's output is where the real risks lie, but memory safety of clang itself doesn't help there.
- sanxiyn 4y agoWell, LLVM being written in C++ is fine for memory safety, but let's not kid ourselves. If LLVM were written in Rust it would have function level parallel compilation already. LLVM compilation is not parallelized yet because it is written in C++.
- mh7 4y ago>If LLVM were written in Rust it would have function level parallel compilation already No one is stopping anyone from writing a compiler backend/optimizer in rust, yet it hasn't happened.
- sanxiyn 4y agoCranelift exists and is in production. Hint: Cranelift does function level parallel compilation.
- azakai 4y agoI don't know enough about why LLVM doesn't use parallel compilation, you might be right there. But there are many C++ compiler codebases that do have it, such as: every major JS/Wasm VM (V8, SpiderMonkey, JSC), Binaryen, etc. Those do run in environments where parallel compilation matters a lot, unlike LLVM (which assumes parallelism in the build system, as you compile to object files).
- sanxiyn 4y agoRust wants parallel LLVM, because Rust has larger compilation unit.
- azakai 4y agoInteresting. That might be very specific to Rust, though. In that case, LLVM might not be the optimal backend for rustc. But this isn't an issue for most LLVM languages, which either assume parallelism in the build system, or they get enough benefit from ThinLTO (which is the parallelism LLVM does support at the link stage).
- morelisp 4y ago> LLVM is written in C++, but that's basically fine. A memory safety exploit in [LLVM] might be annoying, but it's not a vector for taking over people's machines like a browser is. Hrm, is LLVM no longer used for shader compilation? I think most people wouldn't like it if compiling a shader could delete your home directory.
- sanxiyn 4y agoYup, Mesa is no longer using LLVM except for CPU fallback.
- azakai 4y agoIn such cases one can sandbox LLVM, either in another process or using wasm etc., and that has been common for many years. It's practical to do so because it's a pure computation with a clear interface (compile source code to machine code).