by rustacean · 9y ago · 0 comments
[1]:http://cglab.ca/~abeinges/blah/too-many-lists/book/README.ht...
What else is there?
Rust tries to guarantee that you've implemented things correctly and safely, and therefore makes all the formal verification of such into a requirement.
Other low-overhead-bare-metal languages, meanwhile, trust you to have done the formal verification yourself using non-compiler-toolchain tools like linters and static analyzers.
The people who use these other languages who do ensure correctness+safety, will have done all the same work they do in Rust—just using third-party tools instead.
The people who use these other languages but who do not ensure correctness+safety, might seem to have an "easier time", but they will almost always end up with algorithms/data structures that—while seeming to work in most cases—have fatal flaws or vulnerabilities.
To use Rust is simply to sign up for "doing the work" of formally verifying your code up-front, rather than brushing it off as something to think about in some vague, undefined "later."
* Poor ergonomics of raw pointers. Lack of arrow syntax, verbose pointer arithmetic (at least now there is an experimental offset_to).
* Once you have pointers in data structures, properly specifying lifetimes is now your job. Compiler is no longer your friend, but an whisperer of evil (Compiler: Of course it safe. It has 'static lifetime, it must be safe. How do I know, you ask? I saw you dereferencing a pointer).
* Cyclic data structures (without additional layer of indirection) require unsafe, or reference counting and dynamic borrow checking.
* Need to account for zero-sized types when doing pointer arithmetic.
* Need to uphold Rust invariants in unsafe regions of code - forming non-unique mutable references to the same memory is hardly unusual when working with cyclic data structures, or in general (consider for example a swap without checking if memory locations are identical).
It seems to me that Rust moves part of required work from users of data structure to the designer / developer of data structure. You need to invest more work upfront, but once done users don't need to be on constant lookout for accidental API misuse that results in undefined behaviour.