<story><title>The Pain of Real Linear Types in Rust</title><url>https://gankro.github.io/blah/linear-rust/</url></story><parent_chain></parent_chain><comment><author>cwzwarich</author><text>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.&lt;p&gt;The &amp;#x27;dropck&amp;#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&amp;#x27;m wrong), and it has had a lot of soundness issues in the past.&lt;p&gt;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 (&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;aochagavia.github.io&amp;#x2F;blog&amp;#x2F;exploring-rusts-unspecified-drop-order&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;aochagavia.github.io&amp;#x2F;blog&amp;#x2F;exploring-rusts-unspecifie...&lt;/a&gt;) that make it harder to write correct unsafe code.&lt;p&gt;If you were to design a language from the ground up with linear types and no destructors, it would be dramatically simpler than Rust.</text></comment>
<story><title>The Pain of Real Linear Types in Rust</title><url>https://gankro.github.io/blah/linear-rust/</url></story><parent_chain></parent_chain><comment><author>lmm</author><text>As a Scala user: the further I&amp;#x27;ve got into a functional&amp;#x2F;MLey style the more linear my code has become. Options or collections are very naturally handled with &amp;quot;fold&amp;quot; (cata). Loops probably shouldn&amp;#x27;t be infinite - if you&amp;#x27;re looping it&amp;#x27;s usually because you&amp;#x27;re folding along a data structure, and those ought to be finite (one of the ideas I&amp;#x27;m toying with is a type-level natural indexed recursion-schemes like library, to make it easy to construct recursive structures that are known-finite).&lt;p&gt;I don&amp;#x27;t know if it&amp;#x27;s where Rust wants to be, but I want a practical-oriented ML-family language that does this.</text></comment>