“Rust’s compiler prevents common bugs” So does skill. No offense to you, but, this trope is getting so tiresome. If you like the language then go ahead and use it. What is it with the rust crowd that they have to come acrosslike people trying to convert your religion at your front door?

  • mokus@lemmy.blahaj.zone
    link
    fedilink
    arrow-up
    41
    arrow-down
    1
    ·
    4 个月前

    “Should I use rust or c++” is the wrong question IMO. The right question is “do I want the code I run, written by thousands or millions of randos, to be written in rust or c++”.

  • JackbyDev@programming.dev
    link
    fedilink
    English
    arrow-up
    10
    ·
    4 个月前

    I can sympathize with some people getting tired of “rewrite it in Rust”, especially when it’s suggested inappropriately. (Worst I saw was an issue opened on something, maybe a database, I don’t remember. Someone said they were a new programmer and wanted to help and only knew a little Rust and that if the project was rewritten in Rust they could help.) But… Rust’s compiler being able to do those things is actually super useful and amazing. This is like someone saying they don’t need static types because they know the language good enough to not misuse the dynamic types. This is like someone saying they don’t need C because they’re good at assembly.

    While it isn’t something as simple as Rust being strictly better than C/C++, it’s really silly to say that you being a good developer means you don’t need guardrails. Everybody makes mistakes all the time. You’re not perfect.

  • Treczoks@lemmy.world
    link
    fedilink
    arrow-up
    2
    arrow-down
    14
    ·
    4 个月前

    The “common bugs” that the Rust compiler prevents are those a good programmer should not make in the first place. It’s the bugs that even evade a seasoned programmer that poses the problems, and there, Rust won’t help either.

    Remember ADA? A programming language frankesteined by a committee to make programming safer? The programmers using it still produce bugs. And ADA is way more whips and chains than Rust.

    • beegnyoshi@lemmy.zip
      link
      fedilink
      arrow-up
      20
      ·
      edit-2
      4 个月前

      It’s the bugs that even evade a seasoned programmer that poses the problems, and there, Rust won’t help either

      What do you mean these are not the ones that rust tries to fix? Even huge projects like the linux kernel get memory bugs. I don’t know anything about ADA and nor do I want to “evangelize rust” but what you’re saying sounds boggers.

      Obviously rust cannot prevent all bugs or even most of them. It can only prevent a small subset of bugs, but saying that that “small subset of bugs” wouldn’t happen to seasoned programmers is just wrong, especially when you have tons of programmers working on the same big project.

      I don’t mean to say that rust is always the correct choice, but that you’re waving off its greatest offering as bicycle training wheels (i.e. something no seasoned programmer would need)

      • Treczoks@lemmy.world
        link
        fedilink
        arrow-up
        2
        arrow-down
        12
        ·
        4 个月前

        but what you’re saying sounds boggers.

        Believe me, it isn’t. I program about anything for forty+ years now. I probably have forgotten more programming languages than you can list, and if there are constants in programming, then a) while compilers get better at catching bugs, they never got over the basics, and b) a good programmer will alyways be better at preventing and catching bugs than a compiler.

        Once you have aquired a good mindset about disciplined programming, those buglets a compiler (or even code review systems) can find usually don’t happen. Be wary of those bugs that evade the seasoned programmer, though…

        For the mindset, it is good to read and understand things like the MISRA standard. Stuff like that prevents bugs.

        • NotANumber@lemmy.dbzer0.com
          link
          fedilink
          arrow-up
          9
          ·
          edit-2
          4 个月前

          Man hackers would love you. Memory vulnerabilities are still one of if not the main cause of vulnerabilities in unsafe languages. Yes this even applies to large projects ran by experienced and skilled people like the Linux kernel. Stop thinking your the exception, because I guarantee you aren’t but even if you were you can’t read all of the code in the world in your lifetime. Nor can you write all the code in the world.

        • beegnyoshi@lemmy.zip
          link
          fedilink
          arrow-up
          7
          ·
          4 个月前

          I probably have forgotten more programming languages than you can list, and if there are constants in programming, then a) while compilers get better at catching bugs, they never got over the basics, and b) a good programmer will alyways be better at preventing and catching bugs than a compiler.

          I agree with this

          Once you have aquired a good mindset about disciplined programming, those buglets a compiler (or even code review systems) can find usually don’t happen.

          I also agree with this.

          I would like to put a lot of emphasis in the usually. It doesn’t mean that they don’t happen, no human being makes no mistakes. Rust simply gives people a little more peace of mind knowing that unless they use unsafe they’re probably fine in terms of memory issues.


          As a side note, there was this once I was making an ecs engine in rust, and kept fighting the compiler on this issue. Specifically, the game engine bevy uses Query in the World to retrieve information about the game state, and I wanted to do the same. For instance, in the following function (or something similar, I honestly don’t remember all that well):

          fn getplayer(player: Query<Player>) {}
          

          Would get player from the world and assign it to player (more or less). However rust was adamant in not letting me do this. After some thinking I finally realized why

          fn getplayer(player: Query<Player>, player_too: Query<Player>) {}
          

          Would give two mutable references to the same Player in the same function, which can be very easily mishandled, and thus is not allowed in rust.

          I don’t know about the MISRA standard, but I don’t think that using it would have changed the way I coded my inherently flawed approach. This is a small example, one that didn’t even matter that much in the grand scheme of things and could be even hard to understand why it’s bad without knowing rust, but it is the one that came to mind. I think that if I had more experience I would he able to give you one that actually had security implications.

          I’m no seasoned programmer, however

    • douglasg14b@lemmy.world
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      edit-2
      4 个月前

      This is the same kind of argument that you shouldn’t have to wear seat belts because just don’t crash, duh.

      Why do we have traffic lights?? Just don’t hit each other, duh.

      You shouldn’t need emergency shutoffs at gas stations, don’t have a fire stupid!

      Hand rails on stairs? C’mon, just don’t trip.

      Confirmarion dialog on deleting data? Well, just don’t click the wrong thing 🤦

      It’s beyond obtuse

      And completely missed the entire problem of human error. Which is one of the only constants we can always rely upon in every situation in every industry everywhere.

      Being ignorant of something this pervasive and uniform across all humanity is not an excuse.

  • Scoopta@programming.dev
    link
    fedilink
    arrow-up
    25
    arrow-down
    1
    ·
    edit-2
    4 个月前

    While I do totally see the advantages of rust and agree skill is not a solution given people make mistakes…I do agree a lot of the very vocal rust advocates do act almost religious and it is an annoying turn off.

    • daniskarma@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      8
      ·
      4 个月前

      Do you have time to talk about our lord Rust? Did you know it died for our bugs so we don’t have to debug them at run time?

    • Valmond@lemmy.world
      link
      fedilink
      arrow-up
      17
      arrow-down
      1
      ·
      4 个月前

      We had the Java guys in year 2000, at least Rust seems to be a decent language.

      • LeFantome@programming.dev
        link
        fedilink
        arrow-up
        7
        ·
        4 个月前

        Java was created so that teams of intermediate skill programmers could maintain large, long-lived code bases. And it did its job incredibly well.

        If that is not your use case (or you do not want to admit that you are such a programmer), it may not be your favourite language.

        I always like C# far better. It may be my favourite language overall. It has a bit more headroom and was designed somebody far more skilled. But it was designed to compete directly with Java. So, you know who it was built for.

      • zarkanian@sh.itjust.works
        link
        fedilink
        arrow-up
        2
        arrow-down
        1
        ·
        4 个月前

        I’ve never run into a Java evangelist. Every opinion I’ve ever heard about Java is something like “Yeah, this sucks”. I always thought that people put up with it because it’s write-once, run-anywhere, but so is, y’know, Python.

        • Valmond@lemmy.world
          link
          fedilink
          arrow-up
          1
          arrow-down
          1
          ·
          4 个月前

          There was a saying back in the day, roughly: “java can run on all platforms like anal sex works on all genders”.

          Python is slow but fantastic when it comes to interoperability IMO and is just complex enough that you can get the job done. I just hope they’ll won’t complexify it into oblivion, it’s a really neat language. IMO.

        • ZILtoid1991@lemmy.world
          link
          fedilink
          arrow-up
          3
          ·
          4 个月前

          Early on, Java was advertized as the next great thing, ending headaches from system development, porting, and “promoting good programming practices through OOP”.

          Then people increasingly got tired of OOP and the speed penalty of both that paradigm and the JVM, not to mention more and more education institutes started to claim Java was too hard for beginners, and that Python would be better.

          Now we have Rust evangelists promoting the language as the next great thing, ending headaches from memory safety issues, porting (if you target WASM and pack your app into a Chromium instance), and “promoting good programming practices through FP”.

          Time is truly a flat circle…

  • AllNewTypeFace@leminal.space
    link
    fedilink
    arrow-up
    54
    arrow-down
    2
    ·
    4 个月前

    The human mind has limited capacity for things to pay attention to. If your attention is occupied with tiptoeing around the loaded guns scattered all over the floor, sooner or later you’ll slip and trip over one.

    Of course, you’re a virtuoso programmer, so you can pirouette balletically around the floorguns as you deliver brilliantly efficient code. Which is great, until you have an off day, or you get bored of coding, run off to join the circus as a professional knife-juggler and your codebase is inherited by someone of more conventional aptitude.

    Programming languages offering to keep track of some of the things programmers need to be aware of has been a boon for maintainability of code and, yes, security. Like type systems: there’s a reason we no longer write assembly language, squeezing multiple things into the bits of a register, unless we’re doing party tricks like demo coding or trying to push very limited systems to their limits.

    • BatmanAoD@programming.dev
      link
      fedilink
      arrow-up
      27
      ·
      4 个月前

      … until you have an off day, or you get bored of coding, run off to join the circus as a professional knife-juggler and your codebase is inherited by someone of more conventional aptitude.

      Sometimes you even have to deal with having mere mortals on your team!

      • nickwitha_k (he/him)@lemmy.sdf.org
        link
        fedilink
        arrow-up
        7
        arrow-down
        1
        ·
        4 个月前

        It is a way to go but there are still cons there. Guaranteeing memory safety isn’t free. You have to pay for it somewhere, either at compilation time, like Rust, or during runtime like in Go. Both are solid approaches but GC will cause problems in cases where the extra runtime overhead is not acceptable.

  • Omega (she/her)@beehaw.org
    link
    fedilink
    English
    arrow-up
    4
    ·
    4 个月前

    I mean… they do kinda have a point on the last part. I’m no programmer or coder. I can’t code for shit. I don’t know a lot about development. And even I have the feeling that Rust people, they’re kinda like NixOS people a while back, they never shut the fuck up about it. :3

    They’re definitely enthusiastic, I’ll give them that. But so many projects are sold solely on the fact that they are made with Rust, even though it means absolutely nothing to most users.

    I remember when System76 announced that they were making a new desktop environment and the only thing they basically said about it back then was that it was made with Rust and it felt like my corner of the internet lost their mind about it like they had announced the second coming of Christ or something.

  • smiletolerantly@awful.systems
    link
    fedilink
    arrow-up
    135
    arrow-down
    11
    ·
    4 个月前
    • if your skill is so great that you would never cause the kinds of bugs the rust compiler is designed to prevent, then it will never keep you from compiling, and therefore your complaint is unnecessary and you can happily use rust
    • if you do encounter these error messages, then you are apparently not skilled enough to not use rust, and should use rust

    In summary: use rust.

      • smiletolerantly@awful.systems
        link
        fedilink
        arrow-up
        7
        arrow-down
        1
        ·
        4 个月前

        Curious what you are talking about. Multi-threaded sharing of memory for example is also easy with rust, it just doesn’t let you wrote and read at the same time, and so on.

    • Decq@lemmy.world
      link
      fedilink
      arrow-up
      20
      arrow-down
      5
      ·
      edit-2
      4 个月前

      This so true, every one complaining that the borrow checker is annoying isn’t apparently aware what they used to do was inherently flawed. Sure there a some, though rare, false positives. But they are easily mitigated. These people are exactly that what they themselves are complaining about, elitist.

      • smiletolerantly@awful.systems
        link
        fedilink
        arrow-up
        14
        ·
        4 个月前

        Yeah. Once you get used to the (verbose, but by no means unergonomic!) syntax, you’ll probably never be happy with another language again. Job-wise, I am currently mostly using Go, and while also a nice language, I miss the confidence and security I took for granted with rust.

        Not to mention just how goddamn expressive rust can be. Let bindings like if ok/err, else return? Assign from a match on Some(Ok(x))? Filter, map, and friends on any iterator? Oh my GOD the error handling with the question mark iterator? 100% confidence that if it compiles, no error, possible null value, or case is unhandled.

        And all this WHILE giving you the amazing security benefits!

        Ah, damn, caught me proselytizing again.

    • F04118F@feddit.nl
      link
      fedilink
      arrow-up
      38
      arrow-down
      1
      ·
      4 个月前

      I don’t agree with /u/red-crayon-scribbles ’ approach to memory safety, but what you’re saying isn’t entirely true either.

      It is possible to manipulate memory in ways that do not conform to Rust’s lifecycle/ownership model. In theory, this can even be done correctly.

      The problem is that in practice, this leads to the following, many of which were committed by some of the most highly skilled C developers alive, including major kernel contributors:

      https://xeiaso.net/blog/series/no-way-to-prevent-this/

      • Midnitte@beehaw.org
        link
        fedilink
        English
        arrow-up
        21
        arrow-down
        1
        ·
        4 个月前

        …echoing statements expressed by hundreds of thousands of programmers who use the only language where 90% of the world’s memory safety vulnerabilities have occurred in the last 50 years, and whose projects are 20 times more likely to have security vulnerabilities.

        ooof.

  • masterspace@lemmy.ca
    link
    fedilink
    English
    arrow-up
    41
    arrow-down
    2
    ·
    edit-2
    4 个月前

    Skill issue takes are dumb as fuck. It’s just republican personal responsibility takes using different language.

    Intelligent people focus on producing systemically better outcomes.

  • boaratio@lemmy.world
    link
    fedilink
    arrow-up
    4
    arrow-down
    2
    ·
    4 个月前

    At my last job I worked in a code base written in C and it needed to be certified to MISRA level A, and even in a language with as many foot guns as C, it’s possible to write safe code. You just need to know what you’re doing. I know there are tons of Rust zealots out there claiming it’ll solve every last problem, but it turns out you just need to be careful.

  • Tarquinn2049@lemmy.world
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    4 个月前

    Gonna guess, basically the same thing. Easy answers to hard questions instead of you having to think about them.

    So, as far as they would be concerned, the only reason more people haven’t chosen that path must be because they don’t know how much easier it is, and how much less they have to think about stuff.

    They can’t see that building skill and knowledge has value beyond the extra effort.