• patrick@lemmy.bestiver.se
    link
    fedilink
    English
    arrow-up
    15
    ·
    11 hours ago

    I too fixed performance problems in that repo a few years back and did a write up on it - https://jackson.dev/post/rust-coreutils-dd/

    I’m glad this project is getting some more attention, maybe even getting funding from Ubuntu since they’re using it? Last time I touched it most of the code was still pretty clearly written by Rust beginners and non-systems programmers so it likely had/has many such issues to uncover. Ubuntu putting it into their distro should hopefully get more experienced (and actually paid!) devs taking a closer look.

  • Blaster M@lemmy.world
    link
    fedilink
    English
    arrow-up
    12
    arrow-down
    1
    ·
    19 hours ago

    They’ll fix it… sounds like a skill issue, if base64 got fixed and performs better than c

    • chocrates@piefed.world
      link
      fedilink
      English
      arrow-up
      4
      arrow-down
      4
      ·
      17 hours ago

      I’ve heard that while Rust has the ability to be faster than Go and maybe C, it is a lot harder to write rust code to do it

      • ulterno@programming.dev
        link
        fedilink
        English
        arrow-up
        3
        ·
        9 hours ago

        Well, you need to type more and you need to learn more things with Rust, before you can start making stuff.
        But the additional work is to make it easier for you to make changes later, when you come back to it after a while.

        So you might need to do more before hello world, but say if you have a complex library and want to use some function of it after learning Rust, it will be easier to not make some common mistakes.

        A pretty good recent example of something that will cause a common mistake would be:
        In the mongoc library, there is a function named mongoc_client_select_server and the pointer it returns requires destruction using mongoc_server_description_destroy. But it doesn’t say so in the function’s comments/documentation. So, I had to go into the function called by the function called by the function called by it, to find the function making said pointer and having a comment stating that the pointer made by it would require destruction by the user.
        And the only reason I found that out was my obsession, but I had already made the mistake.

      • trevor (he/they)@lemmy.blahaj.zone
        link
        fedilink
        English
        arrow-up
        11
        ·
        edit-2
        15 hours ago

        This is not true. If you know Rust and C equally well, you’re likely going to write equally performant Rust.

        You could say that Rust is harder to learn than C. I’d disagree based on my personal experience, but you wouldn’t be wrong.

  • Luci@lemmy.ca
    link
    fedilink
    English
    arrow-up
    8
    arrow-down
    28
    ·
    19 hours ago

    Rust running slower than C?

    Never would have guessed……

          • BatmanAoD@programming.dev
            link
            fedilink
            arrow-up
            11
            arrow-down
            2
            ·
            14 hours ago

            Πρεσυμαβλυ, ἰτ ἀλρεαδυ ὐσεδ ΣΙΜΔ, ἀνδ θατ’ς ὁ θε ἐξιστινγ ΓΝΥ ὐτιλιτυ βεατ ῾Ρυστ βυ ἀ φακτορ ὀφ 17ξ.

        • trevor (he/they)@lemmy.blahaj.zone
          link
          fedilink
          English
          arrow-up
          9
          ·
          15 hours ago

          I have no idea how. I write better Rust than I do C 🤷‍♂️

          Rust and C are basically identical in terms of performance (more or less). Idk where the myth that Rust is somehow less performant than C came from.

          • Possibly linux@lemmy.zip
            link
            fedilink
            English
            arrow-up
            2
            arrow-down
            3
            ·
            13 hours ago

            It depends on what you are counting as “performance”

            Good C code is way better than mediocre Rust code. C also has much smaller binaries.

              • ulterno@programming.dev
                link
                fedilink
                English
                arrow-up
                0
                arrow-down
                1
                ·
                9 hours ago

                But will a good hello world program, made in JS, run on Firefox on an Embedded Windows 11 OS, running on a CPU emulator running on WASM on Edge be more performant than a mediocre hello world program in C, running on Linux on the same hardware that Edge run on?

            • BatmanAoD@programming.dev
              link
              fedilink
              arrow-up
              3
              ·
              edit-2
              12 hours ago

              If your goal is small binaries, it’s possible to get them with Rust, too: https://github.com/johnthagen/min-sized-rust

              There are a variety of reasons why Rust binaries tend to be bigger unless you follow some of those guidelines, but the biggest one (and actually not something those guidelines recommend changing!) is that C is generally dynamically linked against a system version of the C standard library, whereas Rust binaries are statically linked by default, meaning that the binary is actually self-contained.

              • Samueru_sama@programming.dev
                link
                fedilink
                English
                arrow-up
                1
                ·
                8 hours ago

                whereas Rust binaries are statically linked by default, meaning that the binary is actually self-contained.

                rust still produces larger binaries even if you compare it to static C binaries.

                Take for example busybox, you can compile all of it as a single 1.2 MiB static binary that provides 395 utilities including wget.

                Meanwhile the uutils static musl binary is 12 MiB and only provides 115 utilities.

              • Possibly linux@lemmy.zip
                link
                fedilink
                English
                arrow-up
                1
                arrow-down
                2
                ·
                10 hours ago

                C is still better for the embedded world

                If you have gigabytes of storage and memory Rust makes more sense. C shines as it allows fine control over memory. The fact that you can tie into The system libraries makes it very resource friendly since you don’t need redundant code.

                • zygo_histo_morpheus@programming.dev
                  link
                  fedilink
                  arrow-up
                  2
                  ·
                  8 hours ago

                  You can tailor the rust standard library to be more embedded friendly in several way, like if you don’t have dynamic memory allocation or a filesystem, you can get the standard library sans those features.

                  Rust also gives you a very fine grained level of control of memory, I think equivalent to C (maybe there’s some gotcha that I’m not aware of but if not equivalent very close).

                  It really doesn’t sound like you know that much about Rust here and are just making things up, you certainly don’t need “gigabytes of storage and memory”

                • BatmanAoD@programming.dev
                  link
                  fedilink
                  arrow-up
                  3
                  ·
                  9 hours ago

                  I think you’re making some poorly-researched assumptions.

                  In the embedded world, there often aren’t “system libraries,” depending on just what you’re targeting. But if, for some reason, you really do want to use libc but not the Rust standard library, you can certainly do that; for instance, here’s a crate that reimplements the Rust standard library’s output and formatting capabilities using libc: https://github.com/mmastrac/rust-libc-print

                  Rust provides essentially the same memory control as C does. You can also have inline assembly in Rust, just as in C.

                • ulterno@programming.dev
                  link
                  fedilink
                  English
                  arrow-up
                  0
                  ·
                  9 hours ago

                  Wasn’t Rust originally made for embedded systems to reduce the time taken debugging runtime errors by shifting those to compile time?