3 ms·
Safe Rust prevents you from doing stuff, it just won't compile. More importantly, it prevents your dependencies from doing stupid stuff if they're forbid(unsafe
by aldanor 4y ago
Safe Rust prevents you from doing stuff, it just won't compile. More importantly, it prevents your dependencies from doing stupid stuff if they're forbid(unsafe).
"Safe C++" you can segfault or mem leak in a single line. Good luck reading through a few dozen k lines of code of a 3rd party library to check if they adhere to every single convention of "safe C++".
- karmakurtisaani 4y agoAlso, "safe c++" is still c++. You can write it as safe as you want, but all it takes is one 3 month contractor to come shit all over you codebase and leave. If your company doesn't have enough resources to control what goes in at all times, you will easily get stuck with fixing someone else's memory leaks. At least rust has built-in safeguards against that.
- nequo 4y ago> you can segfault or mem leak in a single line. Good luck reading through a few dozen k lines of code of a 3rd party library You have articulated one of the biggest motivations I have for avoiding C++ in scientific computing. An R library that uses C++ to speed up a clustering algorithm that seemingly arbitrarily segfaults on my input is not the thing I should be having to debug.
- saghm 4y agoI think it's important to note that Rust can still leak memory in safe code. Memory leaks are not "unsafe"; they're a performance issue and could possibly lead to panics due to running out of memory, but panicking is not unsafe (i.e. it's deterministic and not a source of undefined behavior). Rust provides a lot of absolutely critical guarantees, and I fully agree that it's much safer than C++, but I think it's important not to overstate the benefits (not that you did say that Rust prevents memory leaks, but I worry that someone might incorrectly infer that due to the way it was mentioned for C++).