#fishshell rewrite-it-in #rust progress, 2023-11-20

76909 rust lines added

48105 / 77063 C++ lines removed

▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░ 62 %

  • TechNom (nobody)
    link
    fedilink
    English
    arrow-up
    5
    ·
    1 year ago

    I wonder what sort of problems they had with C++ that prompted them to port such an old codebase to Rust.

    • BB_C
      link
      fedilink
      arrow-up
      8
      ·
      1 year ago

      Most specific and technically relevant point:

      • Rust is what we need to turn on concurrent function execution.

      You can read more in the RIIR PR.

      • TechNom (nobody)
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        Not really. Rewriting something in Rust has some obvious advantages. But those advantages diminish with the age of the old code base. For example, the biggest advantage is memory safety. But old C or C++ code bases would have undergone so much real world use and testing that most of the memory safety bugs would have been corrected anyway. Similarly, the new code (in Rust in this case) may fail to capture lessons from the old code that may not be well documented.

        For these reasons, the common approach followed is to wrap old code in safe Rust and use it, instead of completely rewriting it in Rust. This was a stated objective (C & C++ FFI) of Rust project since its early days. This is also the reason why core Rust team often doesn’t support the RiiR zealotry.

        In this case though, the developers of fish themselves decided that the hassles of C++ is worse than completely rewriting such a big and old code base in another language. I’m interested in C++ as well, though Rust is my primary language these days. I thought that it would be interesting to hear the experience of someone who made this unusual decision after dealing with both languages.