A comparison of Rust's borrow checker to the one in C#

(em-tg.github.io)

27 points | by SkiFire13 2 days ago ago

10 comments

  • zigzag312 2 days ago

    I always felt like these features are adding a new programming paradigm to C# that allows you to bypass GC in safe code.

    I wish more people would talk about it. Thank you for such an interesting article!

    • pjmlp 2 days ago

      Many of these features exist since .NET 1.0, given its scope of languages to support, including C++.

      So even those that weren't initially exposed in unsafe mode, were available at the MSIL level and could be generated via helper methods making use of "System.Reflection.Emit".

      Naturally having them as C# language features is more ergonomic and safer than a misuse of MSIL opcodes.

      • zigzag312 2 days ago

        "System.Reflection.Emit" is not compatible with NativeAOT.

        Using C/C++/Rust to do the same task is probably more productive than emitting MSIL opcodes, so that solution wasn't really that practical.

        But with these new features being more ergonomic and practical, it becomes cost effective to just do it in C# instead of introducing another language.

        • pjmlp 2 days ago

          Yeah, but nothing of that is the point being discussed, with Native AOT still not available in GUI workloads.

          Also P/Invoke and CCW/RCW do have costs cross the runtime layer, even if minor when compared with other languages.

          • zigzag312 a day ago

            I'm not sure I follow. Where are GUI workloads being discussed in the article?

            If anything, article doesn't talk about MSIL or CLR, but C# language features. CLR is not the only target C# supports.

            NativeAOT is supported in Avalonia (cross-platform UI framework), Razor Slices (dynamically render HTML from Minimal APIs) and I think there is also some support for AOT in MonoGame & FNA (game dev frameworks).

            However, it's still early and a lot of the ecosystem doesn't support NativeAOT.

            • pjmlp a day ago

              No, neither was Native AOT.

              Native AOT depends on CLR infrastructure.

        • 2 days ago
          [deleted]
  • neonsunset 2 days ago

    What a great article, thank you for sharing it!

  • bob1029 2 days ago

    [flagged]

    • 2 days ago
      [deleted]