• Zacryon@feddit.org
    link
    fedilink
    arrow-up
    2
    arrow-down
    4
    ·
    6 months ago

    If a language prevents you from doing stuff like that, this always comes at a cost, since it has to do the work for you, almost always. This is additional overhead you can get rid of in C++ and therefore gain a lot of performance. But that again comes with more responsibility on the developer’s side and you might need to implement appropriate checks yourself where needed.

      • Zacryon@feddit.org
        link
        fedilink
        arrow-up
        2
        ·
        6 months ago

        It’s not just about runtime performance, but also about coding flexibility, and for example also reduction of boilerplate.

        • lolcatnip@reddthat.com
          link
          fedilink
          English
          arrow-up
          2
          arrow-down
          1
          ·
          6 months ago

          Ah yes, I love how C++ is has so little boilerplate. Sometimes I can even write several statements in a row without any!

          • Zacryon@feddit.org
            link
            fedilink
            arrow-up
            2
            ·
            6 months ago

            You’ve missed the context. There are occasions in Rust where you have to use more boilerplate code which you wouldn’t have to implement in C++ to that extent.

            But saying that C++ is free of boilerplate is of course ridiculous, if you are not able to heavily leverage templates, CRTPs, macros and alike.

    • dreugeworst@lemmy.ml
      link
      fedilink
      arrow-up
      2
      ·
      6 months ago

      sure, maybe, but performance doesn’t matter for deciding if a language is memory-safe or not. And C++ isn’t memory-safe by any commonly used interpretation of that word.

      You may of course decide that the downsides of memory-safety aren’t worth it for your use-case, that is a separate issue

      • Zacryon@feddit.org
        link
        fedilink
        arrow-up
        2
        ·
        6 months ago

        I think it boils down, how we define “memory safe”. C++ is perfectly memory safe, if you know what you’re doing. A lot of people don’t. Which is why Rust was born. that doesn’t make C++ a memory-unsafe language. It just demands more responsibility from the user. A design philosophy that comes with a lot more flexibility than Rust can offer.

        Which is fine. Both languages have their perks. But saying C++ isn’t memory safe, while Rust is, is in my opinion just plainly wrong. Besides, with “unsafe” Rust inherently already the door for memory issues.

        Modern C++ practises and dev patterns can handle most memory issues in C++ pretty easily. Consider smart pointers for example, or RAII.

        It’s not the language’s fault if it is used wrong.