• trevor (he/they)@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    15
    ·
    edit-2
    1 day 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.

    • PlexSheep@infosec.pub
      link
      fedilink
      arrow-up
      4
      ·
      16 hours ago

      I have read papers for my bachelor’s thesis that compared rust and c on x86-64 in terms of performance. It showed that C is a little or significantly faster, depending on the type of workload.

      This is likely due to some runtime checks the rust compiler adds, and modified rust compilers that added less runtime checks led to about the same performance.

      However, the performance is still very good for both languages (native machine code being executed), and in the same order of magnitude.

      My own measurements for the armv6m architecture with an STM-32 showed that rust may even be faster in some cases, since the optimizing of the rust compiler was better, at least for that setup and for the CRC-32 algorithm.

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

        Unless you’re talking about some sort of reference counting, which has to be explicitly added by the programmer in cases where doing so is required for memory safety, I’m not sure what runtime checks you’re referring to?

        From what I’ve seen, the performance of programs written in C and Rust are generally the same, more or less, with C or Rust coming out on top with roughly coinflip odds in a handful of cases. This feels like the primary differentiator in performance really comes down to the implementation of the person writing it, and less to do with any performance differences inherent to either language.