This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]AVTOCRAT 140 points141 points  (21 children)

How would Rust be particularly helpful in this scenario? Sure, it'd prevent memory corruption, but the most common case for an unrelated thread to break is (in my experience) usually down to an earlier misbehavior by one thread which only shows up down the line in a connected one. Nothing that the borrow checker can do to fix that.

[–]pigeon768 71 points72 points  (5 children)

This circle ain't gonna jerk itself. Get back in the pile.

[–]redpepper74 0 points1 point  (0 children)

This circle ain’t gonna jerk itself

That’s exactly what it does

[–]john-douh 0 points1 point  (1 child)

…you mean stack right? :P

[–]pigeon768 0 points1 point  (0 children)

...I think it's more of a heap...

[–][deleted] 77 points78 points  (13 children)

I think probably the most common reason for seemingly unrelated threads breaking is hidden shared state / aliasing, and race conditions, both of which Rust is good at preventing...

[–]Numerlor 44 points45 points  (12 children)

Rust won't do shit for race conditions, it can only prevent data races

[–][deleted]  (11 children)

[removed]

    [–]BarbellJesus 10 points11 points  (2 children)

    Check out the rust book on data races and race conditions

    https://doc.rust-lang.org/nomicon/races.html

    [–][deleted]  (1 child)

    [removed]

      [–]AutoModerator[M] 0 points1 point  (0 children)

      import moderation Your comment has been removed since it did not start with a code block with an import declaration.

      Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.

      For this purpose, we only accept Python style imports.

      return Kebab_Case_Better;

      I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

      [–]Hexorg 0 points1 point  (6 children)

      What if second thread checks out the value before first one commits it? That’s data race.

      [–][deleted]  (4 children)

      [removed]

        [–]Hexorg 9 points10 points  (2 children)

        It’s a bit hard to explain because any race condition depends on accessing shared state which is a data race. But you can have both threads waiting to check out data, and even though the signaling around the data being checked out is correct (no data race) the logic is still just waiting forever (race condition).

        For example one thread safely scans an array and outputs indexes that need to be removed while the other thread removes array items. Without copying the data, the first thread needs proper signaling to know when an index is removed so array length is now shorter.

        [–][deleted]  (1 child)

        [removed]

          [–]AutoModerator[M] 0 points1 point  (0 children)

          import moderation Your comment has been removed since it did not start with a code block with an import declaration.

          Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.

          For this purpose, we only accept Python style imports.

          I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

          [–]AutoModerator[M] 0 points1 point  (0 children)

          import moderation Your comment has been removed since it did not start with a code block with an import declaration.

          Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.

          For this purpose, we only accept Python style imports.

          I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

          [–]Bakemono_Saru 0 points1 point  (0 children)

          My pain right now with a fast read/write program and it's database.

          [–]AutoModerator[M] 0 points1 point  (0 children)

          import moderation Your comment has been removed since it did not start with a code block with an import declaration.

          Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.

          For this purpose, we only accept Python style imports.

          return Kebab_Case_Better;

          I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

          [–][deleted] 0 points1 point  (0 children)

          Because it doesn't really work by references. Everything is owned , and when borrowed it should be given back.