The Pain of Real Linear Types in Rust
A lot of the awkwardness that the author describes comes from destructors, which Rust has taken from C++. In fact, Rust has even inherited the incoherence between destructors and exceptions from C++, due to the lack of a solution to the double-throw problem and the need to write unsafe code that is correct in the face of unwinding.<p>The &#x27;dropck&#x27; pass is one of the corners of the language that has no precedent in a type system that has been proven sound (at least as far as I am aware, someone please correct me if i&#x27;m wrong), and it has had a lot of soundness issues in the past.<p>The fact that destructors have magical powers that the language refuses to bestow on ordinary functions is a bad sign. And destructors are terrible for predictable code: the order in which destructors run for temporary results in a single expression is not even specified by the language, and there are some surprises (<a href="https:&#x2F;&#x2F;aochagavia.github.io&#x2F;blog&#x2F;exploring-rusts-unspecified-drop-order&#x2F;" rel="nofollow">https:&#x2F;&#x2F;aochagavia.github.io&#x2F;blog&#x2F;exploring-rusts-unspecifie...</a>) that make it harder to write correct unsafe code.<p>If you were to design a language from the ground up with linear types and no destructors, it would be dramatically simpler than Rust.