• anyhow2503@lemmy.world
    link
    fedilink
    English
    arrow-up
    22
    arrow-down
    1
    ·
    11 hours ago

    I swear some of these commenters will jerk each other off about how “Rust is bad, actually” even if the root cause of an issue was someone intentionally crashing their app. Where do you even get this kind of attitude from? I’ve been around when Rust was the popular topic in any programming-related discussions and while there was plenty of evangelism and CS-101 experts making wild claims, nothing warrants this kind of irrational hatred. I thought you need to go to the phoronix forums to find people who have such loud opinions with very little actual programming experience, but apparently I was wrong.

    • mostlikelyaperson@lemmy.world
      link
      fedilink
      English
      arrow-up
      10
      arrow-down
      3
      ·
      11 hours ago

      Up until very recently, the cult of rust was going - very - strong on lemmy. Things have somewhat normalized by now, but for a long time, any programming related topic was full off, often ill informed, takes why “rust should have been used for this” and similar things. The Rust community has generally been extremely toxic as well, not helping its reputation. Now that we are a few years in and various major Rust projects have had numerous embarrassing bugs reality has sunk in, but as these things go, the backlash will last longer on the internet than the hype ever has.

      • anyhow2503@lemmy.world
        link
        fedilink
        English
        arrow-up
        11
        ·
        10 hours ago

        The internet would be a much quieter place if people were forced to have a minimal amount of insight into the topic they’re posting about. I guess what really annoys me is when popular blogs like this one deliberately frame something they don’t like in a way that makes it look worse to people who don’t know any better. There are very few people calling this shit out, be it on lemmy or the comments of the article itself. They even lied about FL1 being “bullet-proof” and “unaffected” by this bug, when it clearly wasn’t, according to Cloudflare - the primary source of this shitstain of an article.

      • Semperverus@lemmy.world
        link
        fedilink
        English
        arrow-up
        2
        arrow-down
        7
        ·
        edit-2
        4 hours ago

        I think my biggest gripe with the Culture of Rust is that they keep trying to force it into the Linux kernel and utilities, but even worse than that, they keep trying to replace things WITH DIFFERENT LICENSES. Ones with less system owner protections. Worse ones.

        • anyhow2503@lemmy.world
          link
          fedilink
          English
          arrow-up
          10
          ·
          4 hours ago

          Putting aside the ideological discussion about software licenses, saying that “they” are forcing Rust into the Linux kernel is a bold claim when Linus Torvalds clearly doesn’t mind the inclusion and even encourages it for example in driver code, at least as an experiment.

  • dhork@lemmy.world
    link
    fedilink
    English
    arrow-up
    138
    arrow-down
    2
    ·
    1 day ago

    Just because you’re writing in a shiny new language that never misses an opportunity to crow about how memory safe it is, doesn’t mean that you can skip due diligence on input validation, checking every return value and writing exception handlers for even the most unlikely of situations.

    Lol

      • Noja@sopuli.xyz
        link
        fedilink
        English
        arrow-up
        26
        arrow-down
        2
        ·
        1 day ago

        Memory leaks are logic errors, Rust can’t really prevent you from leaking memory.

          • Mechanize@feddit.it
            link
            fedilink
            English
            arrow-up
            23
            ·
            edit-2
            24 hours ago

            You can leak memory in perfectly safe Rust, because it is not a bug per se, an example is by using Box::leak

            Preventing memory leaks was never in the intentions of Rust. What it tries to safeguard you from are Memory Safety bugs like the infamous and common double free.

            • 8uurg@lemmy.world
              link
              fedilink
              English
              arrow-up
              2
              ·
              5 hours ago

              And it still cleans up once the ownership model indicates it can be cleaned up. That does not ensure memory is never leaked, but it is equivalent to destructors running automatically when using unique ptr or shared ptr without cycles in C++, which avoids at least a portion of possible memory leaks.

        • socsa@piefed.social
          link
          fedilink
          English
          arrow-up
          7
          ·
          1 day ago

          Some memory leaks are logic errors, and this is honestly the irony of modern dynamic languages. I have actually gotten into the argument in interviews before - it is arguably safer (and better) to work from maximal static memory allocations with memory safe data objects than it is to implement dynamic memory algorithms just because they are fun coding problems.

    • wizardbeard@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      8
      ·
      21 hours ago

      I swear, every time I start to think that I go overboard with this sort of shit in my scripts for work, I either find another ridiculous edge case or a story like this comes out.

  • TurboWafflz@lemmy.world
    link
    fedilink
    English
    arrow-up
    69
    arrow-down
    1
    ·
    1 day ago

    It’s crazy that cloudflare of all people even had unwrap enabled. Whenever I use unwrap in some tiny little not important thing I always treat it as a temporary thing that I need to come back and fix before the software is actually ready for anyone to seriously use

      • Mubelotix@jlai.lu
        link
        fedilink
        English
        arrow-up
        13
        ·
        24 hours ago

        Yeah but man, they should have had a CI against this. And reviews! I have refused to merge PRs from friends on hobby projects for less than that

        • Mose13@lemmy.world
          link
          fedilink
          English
          arrow-up
          12
          ·
          edit-2
          19 hours ago

          PM: Listen it’s almost December, the whole team decided to cash in PTO next week for thanksgiving, it’s 4pm on a Friday, and the quarter is about to end. We have to move onto next quarter’s OKRs. Is this good enough to ship?

          A very tired dev: …lgtm

  • HugeNerd@lemmy.ca
    link
    fedilink
    English
    arrow-up
    4
    arrow-down
    19
    ·
    11 hours ago

    Rust starts with the same letters as Russia. I know what’s going on here.

    • HugeNerd@lemmy.ca
      link
      fedilink
      English
      arrow-up
      2
      arrow-down
      14
      ·
      10 hours ago

      Mod me down all you want, I know these “outages” are all orchestrated by powerful state actors who are also weak and backwards. Blaming "Rus"t is as obvious as it gets, next they’ll tell us the guy’s name is "Rus"sell, and to t"rus"t them. I see you.

      • HugeNerd@lemmy.ca
        link
        fedilink
        English
        arrow-up
        1
        arrow-down
        6
        ·
        6 hours ago

        Am I being modded down by all the Russia Russia Russia soap opera addicts who thought knew (because everyone knows) Vladimir Putin himself cut the fibers with his personal favorite potato peeler?

  • ragingHungryPanda@lemmy.zip
    link
    fedilink
    English
    arrow-up
    12
    ·
    1 day ago

    I feel like I’ve seen an insane number of error messages in various apps and websites around the unwrap method.

    But this is on a result type, right? I’d figure the point would be that you would match on it and that the unwrap itself, which if my assumptions are correct, is more like get value or throw, should either not exist or take a default value. You shouldn’t be able to directly get the value of a monad.

    • SethranKada@lemmy.ca
      link
      fedilink
      English
      arrow-up
      24
      arrow-down
      1
      ·
      1 day ago

      There is a function that does what you are asking for.

      .unarap_or()

      It either unwraps the value or uses a provided default. Personally, i think unwrap() should be renamed unwrap_or_panic() to follow existing conventions and prevent confusion for non-rust programmers.

      • Noja@sopuli.xyz
        link
        fedilink
        English
        arrow-up
        5
        ·
        1 day ago

        I don’t think non-rust programmers are programming in Rust, LLMs on the other hand…

        • hummingbird@lemmy.world
          link
          fedilink
          English
          arrow-up
          4
          ·
          12 hours ago

          If you think only llms can do these kind of beginner mistakes you are mistaken. That’s the whole point of the argument.

    • calcopiritus@lemmy.world
      link
      fedilink
      English
      arrow-up
      8
      ·
      1 day ago

      “unwrap should not exist” is true as long as you don’t want to ever use the language. If you actually want to use it, you need it. At least while developing.

      Some values cannot have a default value. And some cases it’s preferable to panic even if it has a default value.

      unwrap is not the problem. Cloudflare’s usage is.

    • cygnus@lemmy.ca
      link
      fedilink
      English
      arrow-up
      13
      arrow-down
      2
      ·
      1 day ago

      I feel like I’ve seen an insane number of error messages in various apps and websites around the unwrap method.

      I suspect this is related to LLM usage somehow. We’ll probably see a lot more of this type of problem (sudden flareups of a particular bad code implementation)

      • ragingHungryPanda@lemmy.zip
        link
        fedilink
        English
        arrow-up
        7
        ·
        1 day ago

        I actually disagree, because I’ve both seen it everywhere and I also work mainly in dotnet, and when I’ve talked to people about option and result types, the first inclination is to have a .Value, but that defeats the purpose. I’ve done quite a few code reviews where I was essentially saying “you know this will throw, right? Use .Match or .Map instead”.

        I think the imperative programming backgrounds encourage this line of thinking, since one of the first questions I’ve gotten is “how do I get the value out of an Option? I’m 100% sure it’s there.” And often, surprise, it wasn’t.

        • cygnus@lemmy.ca
          link
          fedilink
          English
          arrow-up
          2
          ·
          1 day ago

          Could be, but Rust has been around long enough that we’d see this already, no?

          • ragingHungryPanda@lemmy.zip
            link
            fedilink
            English
            arrow-up
            2
            ·
            1 day ago

            Agreed, that’s what I was trying to say but I’m not great at writing. I’ve seen this in rust and other languages long before llms

    • anyhow2503@lemmy.world
      link
      fedilink
      English
      arrow-up
      8
      ·
      1 day ago

      There are good reasons to have unwrap or at least expect. There is no reason to use it in the case that Cloudflare used it in.

  • anon5621@lemmy.ml
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    3
    ·
    1 day ago

    It not exactly unwrap fault even if it would wrote in other way it still not work cause of wrong SQL request which spamming with results longer than expected to rust here was protecting from memory leak actually

    • sugar_in_your_tea@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      3
      ·
      11 hours ago

      It is unwrap’s fault. If they did it properly, they would’ve had to explicitly deal with the problem, which could clarify exactly what the problem is. In this case, I’d probably use expect() to add context. Also, when doing anything with strict size requirements, I would also explicitly check the size to make sure it’ll fit, again, for better error reporting.

      Proper error reporting could’ve made this a 5-min investigation.

      Also, the problem in the first place should’ve been caught with unit tests and a test deploy. Our process here is:

      1. Any significant change to queries is tested with a copy of production data
      2. All changes are tested in a staging environment similar to production
      3. All hotfixes are tested with a copy of production data

      And we’re not a massive software shop, we have a few dozen devs in a company of thousands of people. If I worked at Cloudflare, I’d have more rigorous standards given the global impact of a bug (we have a few hundred users, not billions like Cloudflare).

    • NGram@piefed.ca
      link
      fedilink
      English
      arrow-up
      20
      ·
      1 day ago

      No, the article is just not very precise with its words. It was causing the program to panic.

      • dan@upvote.au
        link
        fedilink
        English
        arrow-up
        5
        ·
        1 day ago

        They’re probably trying to write it in a way that non-Rust-developers can understand.

      • sugar_in_your_tea@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        3
        arrow-down
        2
        ·
        edit-2
        11 hours ago

        No, it’s a panic, so it’s more similar to a segfault, but with some amount of unwinding. It can be “caught” but only at a thread boundary.

        • calcopiritus@lemmy.world
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          2 hours ago

          An unhanded error will always result on a panic (or a halt I guess). You cannot continue the execution of the program without handling an error (remember, just ignoring it is a form of handling). You either handle the error and continue execution, or you don’t and stop execution.

          A panic is very far from a segfault. In apparent result, it is the same. However, a panic is a controlled stopping of the program’s execution. A segfault is a forced execution stop by the OS.

          But the OS can only know that it has to segfault if a program accesses memory outside its control.

          If the program accesses memory that it’s under it’s control, but is outside bounds, then the program will not stop the execution, and this is way worse.

          EDIT: As you said, it’s also an important difference that a panic will just stop the thread, not the entire process.

  • just_another_person@lemmy.world
    link
    fedilink
    English
    arrow-up
    12
    arrow-down
    20
    ·
    20 hours ago

    RUST AGAIN.

    Just throwing this out because I’ve been hammering this Rustholes up and down these threads who claim it’s precious and beyond compare 🤣

    I will almost certainly link back to this comment in the future.

    • lmmarsano@lemmynsfw.com
      link
      fedilink
      English
      arrow-up
      5
      ·
      5 hours ago

      Programmer explicitly bypasses code safety with unwrap.
      Let’s blame it on their programming language!

      Cool hot take, brah.

    • sugar_in_your_tea@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      11
      arrow-down
      1
      ·
      11 hours ago

      Ift is precious and beyond compare. It has tools that most other languages lack to prove certain classes of bugs are impossible.

      You can still introduce bugs, especially when you use certain features that “standard” linter (clippy) catches by default and no team would silence globally. .unwrap() is very controversial in Rust and should never be used without clear justification in production code. Even in my pet projects, it’s the first thing I clear out once basic functionality is there.

      This issue should’ve been caught at three separate stages:

      1. git pre-commit or pre-push should run the linter on the devs machine
      2. Static analysis checks should catch this both before getting reviews and when deploying the change
      3. Human code review

      The fact that it made it past all three makes me very concerned about how they do development over there. We’re a much smaller company and we’re not even a software company (software dev is <1% of the total company), and we do this. We don’t even use Rust, we’re a Python shop, yet we have robust static analysis for every change. It’s standard, and any company doing anything more than a small in-house tool used by 3 people should have these standards in place.