• ZILtoid1991@lemmy.worldOP
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    4 days ago

    The “better” performance is due to the built-in multi-threading support, and that functional programming makes it relatively safer to pull off. Otherwise single-threaded Rust is very hard to optimize.

    • anton@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      1
      ·
      2 days ago

      Rust has monomorphisation like C++ and every function has the aliasing guarantees of restrict, a keyword rarely seen in C code bases use and C++ doesn’t even support.
      This means you can get more optimisations while writing in an intuitive style, where C/C++ requires some changes to the code.

      On the other hand rustc has some hiccups with argument passing and rvo. One could argue that that’s just the compiler while the aliasing problems are part of the language in the C/C++ case, but while there is only one rust compiler its performance is the languages performance.

      For most use cases they are about equally fast.