<story><title>Rust solves the problem of incomplete Kernel Linux API docs</title><url>https://vt.social/@lina/113056457969145576</url></story><parent_chain></parent_chain><comment><author>dagmx</author><text>This is one of the biggest advantages of the newer wave of more expressively typed languages like Rust and Swift.&lt;p&gt;They remove a lot of ambiguity in how something should be held.&lt;p&gt;Is this data type or method thread safe? Well I don’t need to go look up the docs only to find it’s not mentioned anywhere but in some community discussion. The compiler tells me.&lt;p&gt;Reviewing code? I don’t need to verify every use of a pointer is safe because the code tells me itself at that exact local point.&lt;p&gt;This isn’t unique to the Linux kernel. This is every codebase that doesn’t use a memory safe language.&lt;p&gt;With memory safe languages you can focus so much more on the implementation of your business logic than making sure all your codebases invariants are in your head at a given time.</text></comment>
<story><title>Rust solves the problem of incomplete Kernel Linux API docs</title><url>https://vt.social/@lina/113056457969145576</url></story><parent_chain></parent_chain><comment><author>devnull3</author><text>In the beginning, I was trying to use Rust like C (which I think lot of people do) and was struggling with the borrow checker. I had a light bulb in my head one day to read the function signature and see if its &amp;#x27;&amp;amp;self&amp;#x27; or &amp;#x27;&amp;amp;mut self&amp;#x27;.&lt;p&gt;If any one API of a struct&amp;#x2F;enum has &amp;#x27;&amp;amp;mut self&amp;#x27; then its instance cannot be shared across threads without using a mutex (which brings its own friend along i.e Arc). This led me to structure the code in my mind much in advance to prevent borrow checker issues.&lt;p&gt;Another use of this is while embedding an object in a struct. When I realized that &amp;#x27;&amp;amp;mut self&amp;#x27; infects everything up the call chain it was a big learning moment. That is the embedding struct also needs a mutable borrow as well.</text></comment>