• adb@lemmy.ml
    link
    fedilink
    English
    arrow-up
    4
    ·
    6 days ago

    “Before rust you could either have a fast language (C/C++) or a memory safe language (any other language. That is, languages with garbage collector).”

    Ada managed to do safe and fast over forty years ago.

    • BatmanAoD@programming.dev
      link
      fedilink
      arrow-up
      6
      ·
      6 days ago

      Before Rust, the main argument I heard from C++ enthusiasts against Ada was that it was a nice idea but too “design-by-committee”. Which, yeah, is an ironic thing for C++ fans to say, but I guess that was enough 🤷

      • adb@lemmy.ml
        link
        fedilink
        English
        arrow-up
        1
        ·
        5 days ago

        I’ve never used Rust but from my very cursory knowledge of what the borrow checker entails, it wouldn’t add so much to Ada.

        Use of pointers is already strongly discouraged by the simple fact that the language is designed to rarely truly need them. Besides, the compiler itself chooses automatically whether to pass data by value or by reference depending on the required results and what is most efficient. You can also specify parameters passed to a function as read-only. Finally, another thing that Ada does to prevent yourself shooting in your foot is to enforce strong encapsulation of functions and data.

        Overall, one way to put it in simple terms is that Ada requires the programmer to give enough information to the compiler so as to ensure that it actually outputs what you want it to, which as far as I understand, is sort of what the borrow checker is there for. The downside to the Ada approach is that it is very verbose, but with the kind of code editing capabilities we have nowadays it’s certainly not as much a hassle as it was when Ada came out.

        Anyways, I suspect that both languages are different enough in overall paradigm that trying to solve problems in Ada the way you would in Rust would probably be quite frustrating and give rather poor result.

        • bitcrafter@programming.dev
          link
          fedilink
          arrow-up
          1
          ·
          5 days ago

          The borrow checker is a lot deeper than merely making pointer use a bit safer; it provides a model for data ownership based on affine types.

          Also, to the extent that “Ada requires the programmer to give enough information to the compiler so as to ensure that it actually outputs what you want it to,” if I understand you correctly, that is basically true of every language with a static type system. At the extreme end, we have dependently typed languages which essentially let you express arbitrary mathematical propositions in your types and, if the program compiles, then you know that they will always be satisfied without having to do any checks at runtime.