1. 42
  1. 8

    Also, there are a lot of articles on Lobsters that follow this antipattern:

    Explain why most people are doing (with a huge wall of text) then a few words on why that’s wrong and then a shorter wall of text about what the right way is.

    Instead, please start the articles with the right way and then put the “this is in contrast to what most people do, which is [put that wall of text in here] and the difference/reason is [put explanation here]”. I.e. the writing is fine, just not the order. Often feel like this goes for more than half the articles on here. I get that this fits a chronological “narrative” but it buries the lead and makes it harder to learn the new stuff.

    In this case, it didn’t really explain the new stuff. How can AtomicU32 work with a shared reference? We get why it needs to be shared but how can it work, how does it avoid blowing up etc? It kinda skimped on the second part.

    1. 11

      I found the article’s ordering logical because it starts with the beginner’s mental model, which is also the mental model most people have and the mental model of the article’s target audience, and then demonstrates why you’d want to get rid of that mental model.

      1. 7

        Another angle is that beginner’s model isn’t necessary wrong, it’s just simplified and not always applicable. Compare with Physics, where we generally teach Newton’s laws first.

        1. 2

          Very true, my wording was too harsh. I’d edit it but apparently I can’t.

        2. 2

          This fits a chronological narrative but it buries the lede and makes it harder to learn the new stuff.

          “Hi, here are over six hundred words on how it doesn’t work”.

          the mental model most people have

          That’s why do put it in, but at the end. Sure, maybe most or even just some people do have that model. But the right model is relevant for everyone, not just for those who think like the example beginner the author had in mind.

          Me, coming from coroutines, mutexes, and Clojure atoms I was really struggling with trying to learn (and then unlearn) the first 80% of the post. And then felt like it left me hanging without really explaining the right mental model (which @denys_seguret did here in the thread instead, awesome).

          Imagine you’re gonna teach British driving. If driving schools were a typical hacker-written article posted on Lobsters, they’d be like “Let’s start by spending a few weeks driving on the right side of the road like they do in America and some other countries” and then you get a three second diff at the end.

          I do it too, sometimes. For example, my documentation for strse assumes you know how to use irregex. Which is dumb because the entire point of strse is to make irregex easier and more convenient to use. I’ll go fix that when I get some time.

      2. 1

        Mnemonic to remember which is which (since it’s called &mut not &excl): Muttley (from Wacky Races) showered in diiamonds, with a huge diamond ring, sitting on a giant canister of TCRI. (Weirder mnemonics are usually easier to remember ♥)

        1. 15

          I don’t know if it really helps but a &mut reference looks a lot like a compile time mutex as it ensures there’s no reading nor modification while you lock the resource to modify it (more precisely it looks like a RW lock).

          So you can try to remember “mut is for mutex”.

          1. 2

            That’s way easier to understand than the article! Thank you.

          2. 3

            Thanks for commenting. As a rust beginner, I find this statement confusing:

            And &mut T is not a “mutable reference” — it is an “exclusive reference”.

            If I wrote a comment above code like this, I’d probably use this as feedback that my code is not clear. It’s a nice trick to rewire mut as mutex, that’s great as truth/touchstone. But it really is short for mutable. 🌥 I’m not trying to correct you or the language’s past choices here, just saying there’s an extra step. Like a &reference itself, heh.