TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Learning rust with entirely too many linked lists (2019)

99 pointsby 0xedbover 3 years ago

5 comments

tialaramexover 3 years ago
This article offers a list of the very few occasions when a linked list is actually the correct data structure including:<p>&gt; You&#x27;re doing some awesome lock-free concurrent thing.<p>Here&#x27;s an actual example of an &quot;awesome lock-free concurrent thing&quot; that indeed needs linked lists, Jon Gjengset re-implementing (most of) Folly&#x27;s Hazard Pointers but in Rust and he eventually checks they work correctly and have decent performance:<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;playlist?list=PLqbS7AVVErFgO7RUIC6lhd0UekFMbjJzb" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;playlist?list=PLqbS7AVVErFgO7RUIC6lh...</a><p>Unlike the &quot;too many linked list&quot; stuff this is <i>not</i> a Rust tutorial and you should <i>not</i> try to learn Rust by following how this is done. But if you know Rust pretty well it&#x27;s a pretty interesting watch. This is definitely past the point where safe Rust is enough to get work done. Rust has no idea why hazard pointers could be OK, so Jon will be responsible for delivering Rust&#x27;s fabled safety in his implementation any time he needs to write &quot;unsafe&quot; - or else everything catches fire. I think it might also be interesting for C++ programmers who know how Folly&#x27;s Hazard Pointers work and would like to just see what Rust looks like when used on real problems rather than starting with Hello World and the Fibonacci numbers.
DenseCometover 3 years ago
It&#x27;s not obvious (unless you follow the author on twitter[1]) but a large portion of this has been rewritten with new content. Among other things, it now includes a section on detecting undefined behavior in unsafe blocks using Miri[2], which is incredibly neat.<p>[1] <a href="https:&#x2F;&#x2F;twitter.com&#x2F;Gankra_&#x2F;status&#x2F;1486928208528293888" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;Gankra_&#x2F;status&#x2F;1486928208528293888</a> [2] <a href="https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;miri" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;miri</a>
brundolfover 3 years ago
This post was absolutely essential for me when it came to learning &quot;how to think in borrow-checker&quot;. Following the errors, how to respond to different ones, what they mean, which standard library constructs you&#x27;re going to use over and over, how to restructure your data to avoid ownership friction. This is the missing supplement to the Rust Book, as far as I&#x27;m concerned. I recommend it to every new rustacean I can.
Animatsover 3 years ago
That seems the hard way to do backlinks.<p>Backlinks as weak links work. It&#x27;s not symmetrical, but it&#x27;s sound. Forward links then must be Rc&lt;RefCell&lt;T&gt;&gt; links, while backlinks are Rc&lt;Weak&lt;T&gt;&gt;.<p>This also generalizes to the thread safe form, Arc&lt;Mutex&lt;T&gt;&gt;.
blurkerover 3 years ago
I&#x27;ve only skimmed the first few sections but so far I&#x27;m loving what I see! I just started learning Rust and have been going through &quot;The Rust Programming Language&quot; book. Now I&#x27;m tempted to switch to this.<p>My favourite formats to learn from are the &quot;learn while you build&quot; types where you get a good combination of the &quot;how&quot; and the &quot;why,&quot; which this seems to be doing.<p>I really appreciate this being shared! Thanks to the authors for writing the book and OP for bringing it to my attention here on YC &lt;3<p>edit: and if anyone else has suggestions of similar resources I&#x27;d love to hear about those too :D
评论 #30327182 未加载
评论 #30327282 未加载