- Joined
- Jul 14, 2019
Gronk like not to think about memory of living sand but still want best result. Better?Rust "alleviates the cognitive burden" of managing allocation lifetimes the way that wearing a diaper "alleviates the cognitive burden" of going to the bathroom to take a shit.
I see no problem with using unsafe blocks, especially for things like this that are verifiably safe, but only violate rust's ownership model. Whoever implemented std:However, the cleverness that you have to wrap in "unsafe" does help your performance, and things like intrusive doubly-linked lists are not, in fact, unsafe in any way

I would have rather shilled all of the reasons I like rust for, but "the borrow checker" is what is relevant to the discussion, not the incredible expressiveness of the type system or the enums or the pattern matching or the monadic error handling or the cross platform standard library or the closures or slices. "The borrow checker" or the promise of memory safety is not the reason I keep using rust for, it just incidentally makes that promise alongside being a great programming language for general programming. I don't like shilling for muh borrow checker, in fact I hate shilling for muh borrow checker, but it is still fantastic and worth it when it saves your ass, but most importantly people on The Internet are wrong about it and must be corrected.No offense, but the people I have met who shill the borrow checker the hardest are the ones who either have comparatively little experience with either C or C++ and aren't good at dealing with manual memory management. They get on their high horse about how easy it should be to get your code to compile (exactly as you did) if you are an experienced C programmer. However, if you are an experienced C programmer, you understand that the approach you are forced to use is not the best one.
They are not banned by "the borrow checker" and using unsafe blocks does not bypass "the borrow checker", all it really does is make undefined behavior legal, and in order to satisfy rust's borrowing rules to implement a proper doubly linked list, you must write some code that does some accessing of memory through a raw pointer which is classified as undefined behavior, but in reality the raw pointer is created from an existing non-nullable pointer anyways, so the use of unsafe is totally fine. The cult will scree and cry and shit themselves over this because muh safety (you did the heckin' unsaferino!) but really it's just an interesting note about the internals of a data structure that is used less and less these days thanks to performance gains from using contiguous arrays that fit into the cache lines of modern CPUs. Abstract data structures like graphs, trees and linked lists are a guaranteed cache miss, but we still need abstract data structures anyways, and most of them can be expressed easily within rust's type system and ownership model without the need for undefined behavior for no additional runtime performance cost.the borrow checker bans them and the community of Rust shills screams "they aren't that useful anyway"