• onlinepersona@programming.dev
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    9 days ago

    There’s a paper about this and with C as the baseline, Rust was 4% slower for the specific tests they ran.

    In these tests, Rust is actually faster than C sometimes.

    So it really does depend on the workload. However, the safety that rust provides cannot be understated. It’s easy to cut corners like in C, but it’s difficult to do it right. Rust provides the closest result of right and fast.

    Anti Commercial-AI license

    • GolfNovemberUniform@infosec.pub
      link
      fedilink
      English
      arrow-up
      0
      arrow-down
      2
      ·
      9 days ago

      I do agree with you. Safety is important nowadays. Though if there’s a use case where Rust gets a very noticeable performance disadvantage (like UI), it may be better to just use C.

        • qaz@lemmy.world
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          9 days ago

          I wrote a GTK application in Rust some time ago and it was filled with macros to deal with lifetime issues. Most issues could only be solved with unsafe macros or Rc<RefCell<T>>. The experience working with it is probably a lot better when using newer declarative frameworks, but using it with a toolkit written for C wasn’t fun.

          I personally prefer it for cli programs. The executables are considerably larger than C programs due to static linking, but that does mean that it works regardless of what libraries you have installed without any hassle.

            • qaz@lemmy.world
              link
              fedilink
              English
              arrow-up
              1
              ·
              9 days ago

              Yeah, I wrote two “plugins” some time ago and the Assembly implementation was shorter than the Rust implementation due to the need to convert from C ABI and back 😅.

              I have taken a look at both Slint and Egui before, but they didn’t seem to integrate that well with the Linux desktop last time. I just checked again and it seems like Slint has a Qt backend now which is nice. I don’t really like immediate GUI frameworks, but JavaFX has so far been my favorite framework to work with so maybe I’m just weird.

              And yes, I have used min-sized-rust’s tricks for several of my projects, and it’s very effective. However statically compiling just doesn’t compare to using C and linking with the system libraries.

        • GolfNovemberUniform@infosec.pub
          link
          fedilink
          English
          arrow-up
          1
          arrow-down
          2
          ·
          edit-2
          9 days ago

          Someone said Rust wasn’t very good at UIs in terms of performance. Though I don’t remember where it was published.