• 1984@lemmy.today
    link
    fedilink
    arrow-up
    3
    arrow-down
    41
    ·
    24 hours ago

    Let us know when the borrow checker is optional so I can write it without hurting my brain.

    • sugar_in_your_tea@sh.itjust.works
      link
      fedilink
      arrow-up
      5
      ·
      10 hours ago

      Maybe use zig then? It’s unsafe (i.e. no borrow checker) and really fast.

      But honestly, after learning good patterns, I rarely run into borrow checker issues.

    • django
      link
      fedilink
      English
      arrow-up
      7
      ·
      12 hours ago

      If you use it long enough, the borrow checker will change your brain. Embrace the change, it will help you.

    • Cpo@lemm.ee
      link
      fedilink
      arrow-up
      6
      ·
      edit-2
      12 hours ago

      I am in the process of learning rust by creating software for my own use.

      While the borrow checker feels like “fighting the compiler” at times (it took me a week before it started to land, and i have used my share of programming languages!), you will learn.

      I compare this to the C world where you can have quite complex constructs with pointers and references. That used to be hard as hell as well. Until it clicks.

      The only difference is that in C land, your software will segfault during runtime. In Rust your code will complain during compilation.

      Rust without borrow checker is just a bad version of C in my opinion. Rust with borrow checker actually brings value.

      In rust it is still possible to make circular references and cause memory leaks but it is very less likely.

      So: i understand where you are coming from but give it a chance to land. I am glad I did.

      The only thing which is bothering me at times is that the Rust community can come across as highly unfriendly/intolerant at times (comparable to the scala community, which in effect killed the adoption of scala).

      The response to your comment should not have been burning it to the ground but to ask why the borrow checker does not click for you.

      I can highly recommend the series “lets get rusty” on YT from Bogdan. He is explaining the main constructs in very easy to follow instructions videos.

      Have a look and see if it makes it work for you!

    • sabin@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      15 hours ago

      There does exist a crate that allows you to turn it off. Unfortunately the compiler will still compiler your code assuming the same exclusive access rules imposed by the borrow checker, so any time you break the borrow checker rules you’re basically guaranteed to segfault.

      The rust compiler always assumes mutable pointers are exclusive. This is the crux of your issue with the borrow checker. If you don’t make this assumption, then you can’t automatically drop variables when they fall out of scope, thus the programmer would have to manually allocate memory.

      You may prefer even then to allocate memory yourself, but if I was you I would just trust the rust compiler in its assumption that it can optimize programs much better when all pointers are exclusive, and learn to program in a compliant manner

    • thingsiplay@beehaw.org
      link
      fedilink
      arrow-up
      13
      ·
      21 hours ago

      What’s the point of using Rust, if you don’t want to think and program in Rust? If you seriously don’t want to learn and deal with safe code and think every step of it in advance before compilation, then Rust is the wrong language for you. Either use a low level language like C and Zig, which gives you control over the system, but does not have a borrow checker. Or use a language with a runtime check that does this automatically for you without a borrow checker, like Go in example.

      • 1984@lemmy.today
        link
        fedilink
        arrow-up
        2
        arrow-down
        1
        ·
        15 hours ago

        Or zig. Heard a lot about that one. Haven’t really done any serious testing though.

    • BB_C@programming.dev
      link
      fedilink
      arrow-up
      5
      arrow-down
      6
      ·
      16 hours ago

      Bait or not, I’m not sure why you’re getting such a negative reaction. People are getting too sensitive!

      Btw, do sanitizers hurt your brain too?

      • 1984@lemmy.today
        link
        fedilink
        arrow-up
        3
        arrow-down
        6
        ·
        15 hours ago

        Yeah… I’ve written about this sensitivity before on Lemmy. :) I honestly think this platform is best for memes and agreeing with popular opinions. And that’s fine I guess.

        • TehPers@beehaw.org
          link
          fedilink
          English
          arrow-up
          8
          ·
          10 hours ago

          I’m not sure what you’re expecting people to reply with when commenting that in a Rust community. People here tend to use and like Rust, so it’s a bit odd to make sarcastic remarks here about one of Rust’s biggest features and expect people to react well.

          • 1984@lemmy.today
            link
            fedilink
            arrow-up
            1
            arrow-down
            3
            ·
            edit-2
            8 hours ago

            I don’t know, I guess I thought a rust community could have different opinions about Rust. I’m a bit older and I’m OK with people posting negative stuff about things I like without downvoting them. :)

            I don’t have that need to push down opinions I don’t agree with. I guess I just don’t see myself as needing to do that. I don’t feel angered by that sort of stuff.

            • witx@lemmy.sdf.org
              link
              fedilink
              arrow-up
              5
              ·
              6 hours ago

              But you didn’t give your opinion. You made a low effort snarky comment about the most defining feature of the language. And then, you cry people are sensitive…

              Nice troll

              • 1984@lemmy.today
                link
                fedilink
                arrow-up
                1
                arrow-down
                1
                ·
                2 hours ago

                It’s fascinating to see you think that… I mean, it’s also a form of entertainment to realize that people like yourself overreact to things and have no idea that what they think is wrong. Anyway, have a good one. :)

      • KillTheMule@programming.dev
        link
        fedilink
        arrow-up
        10
        arrow-down
        1
        ·
        23 hours ago

        unsafe does not disable the borrow checker. It does however give you abilities to circumvent it, namely by letting you dereference pointers, which are not subject to the borrow checker.

        • ulterno@programming.dev
          link
          fedilink
          English
          arrow-up
          6
          ·
          23 hours ago

          OIC. I really need to start learning this language soon, or I won’t be able to understand future memes and rants.