4 ms·
Surely the point of Rust is 'safety at the price of performance' and if extra performance is required, don't use Rust. Don't bodge the language to accommodate!
by briansm 1y ago
Surely the point of Rust is 'safety at the price of performance' and if extra performance is required, don't use Rust. Don't bodge the language to accommodate!
- int_19h 1y agoIt is not. If it were, it wouldn't even have raw pointers, for example.
- briansm 1y agoand yet an article about a 'safe' language has code examples full of 'unsafe'... wut.
- panstromek 1y ago`unsafe` is just a barrier between what compiler proves and what programmer proves. People should really read more on safety semantics in Rust before making comments like this, it's quite annoying to bump into surface level misunderstandings everytime Rust is mentioned somewhere.
- hmry 1y agoIn normal safe code, the compiler ensures your code has no UB. In an unsafe block, the programmer ensures the code has no UB. Safe abstractions are created out of unsafe operations by making sure it's impossible to violate the operations' preconditions. Either by checking at runtime and returning an error or aborting the program if they're violated, or by using the type system and borrow checker to verify them at compile time (writing the code such that any program that could violate the preconditions must have a type error.) If Rust didn't have unsafe, the only way to access the underlying unsafe operations would be dropping down to C/C++/Assembly, or hardcoding them in the compiler. This is what other languages do, and it's ergonomically worse because the barrier to adding a whole new language and build system to your project is quite high.
- panstromek 1y agoThe point of rust is explicitly not 'safety at the price of performance', quite the opposite. The whole point was to create language where safety doesn't cost performance like it does in most other languages.