• lysdexic@programming.devOPM
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    11 months ago

    the fact that it’s possible (and not even especially difficult) to misuse smart pointers

    Any tool can be misused, but there’s a saying about those who blame the tools.

    If you use a component designed to take over the ownership of an object but somehow make the mistake of assigning the same object to multiple components, the problem is not the language you’re using. The problem is that you aren’t paying attention to what you’re doing.

    • 5C5C5C@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      11 months ago

      That’s awfully reductive.

      Tools can absolutely vary in their qualities and in their risks / benefits. I don’t know what kind of engineer wouldn’t evaluate their choice of tools before using them. If you have a tool that explodes in your face when it gets jostled, that’s a badly designed tool.

      If you have no other choice for the work you need to do, then okay… get very good at using the dangerous tool. But if an alternative tool exists that is not only safer but also more efficient, easier to use, and more productive in every use case then the biggest problem really is the choice of tool.

      • lysdexic@programming.devOPM
        link
        fedilink
        English
        arrow-up
        2
        ·
        11 months ago

        That’s awfully reductive.

        It really isn’t. Otherwise there would be programming languages out there that would make it impossible to write buggy code, and there is nothing of the sort.

        Tools can absolutely vary in their qualities and in their risks / benefits.

        You still get bugs. This isn’t up for discussion. In fact, the only difference is that somehow you assert that C++ suffers from this issue but started to backpedal when any language other than C++ is brought into the picture. That hardly sounds like a personal assertion that’s grounded and well founded.

        • 5C5C5C@programming.dev
          link
          fedilink
          arrow-up
          2
          ·
          11 months ago

          What exactly have I backpedaled on in any of my replies?

          Rust.

          Rust eliminates entire categories of bugs at compile time with performance that is on par with C++ and often better.

          I do get bugs in my Rust code, but do you want to know what they are? Once in a while I forget to type a ! in an if-statement. Or I accidentally type && when I meant to type ||. These mistakes are trivially caught in unit tests or with a single run of the application and easily fixed. It’s also very rare for me to actually make these mistakes. Almost every single time I compile my Rust code, everything works on the first try. But I confess, once in a while one of these minor bugs slips in there.

          So yes bugs are possible in every language. But there’s a lot to be said about what kinds of bugs are possible, what the risks of those bugs are, and what the process of mitigating them is like. A memory corruption bug is an entirely different beast from a simple Boolean logic bug.