4 ms·
Rust is safer than Python though, at least until the inevitable Rust rewrite of cpython. A hosted language is going to inherit the safety or lack thereof of the
by User23 2y ago
Rust is safer than Python though, at least until the inevitable Rust rewrite of cpython. A hosted language is going to inherit the safety or lack thereof of the host language, barring a level of rigor (think theorem proving) that so far as I know cpython doesn’t have.
- mysterymath 2y agoMeh. Rust's safety guarantees typically depend on: - Soundness of their semantics at a conceptual level - Correct implementation of the semantics in rustc (in Rust) - Correct translation of those semantics to LLVM IR targeting OS syscalls in rustc (in Rust) - Correct translation of LLVM IR to native code in LLVM (written in C++) - Correct implementation of OS syscalls (typically in C) Python's safety guarantees typically depend on: - Soundness of their semantics at a conceptual level - Correct implementation of the semantics in CPython (in C) - Correct translation of C to LLVM IR targeting OS syscalls in Clang (in C++) - Correct translation of LLVM IR to native code in LLVM (written in C++) - Correct implementation of OS syscalls (typically in C) Both are typically contingent on correct implementation of a huge swath of C/C++ and Rust code. Even if the entire stack were written in Rust, it still wouldn't be sufficient to guarantee memory safety, since bugs anywhere in the stack could introduce memory unsafety into compiled Rust code. Rust's guarantees come entirely at the first two layers of the stack: If the semantics are sound, and the semantics are implemented correctly in rustc, then the generated LLVM IR (treated abstractly) has memory safety. Python has similar guarantees: if its semantics are sound, and the semantics are implemented correctly in CPython compiler/interpreter, then the resulting execution of the interpreter has memory safety.