Announcement

Collapse
No announcement yet.

Corrode Making Progress On Translating C To Rust

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    It would be cool to convert a unix userland to rust (sbase? toybox?)

    Comment


    • #22
      Originally posted by nerdopolis View Post
      Windows, you need to be admin to create symlinks IIRC
      Thats wrong. You can allow it in the local Security Settings.

      Comment


      • #23
        If it were possible to automatically convert a C code to the Rust, there would be no need in the Rust at all. The Rust allows to specify an additional information about who owns resources and who and how accesses these resources. If you have some tool that can extract this information from more or less sophisticated C code, there is no point to convert anything to the Rust, you can just use a part of this converter as a statical analyzer.

        Comment


        • #24
          Next, a tool to convert Rust code to C for performance reasons.. write your program and test in Rust, to prove it's good, then convert to make it run fast.
          Only half kidding.

          Comment


          • #25
            Originally posted by ssokolow View Post

            There are two parts to translating a codebase from one language to another: Ensuring equivalent functionality, and then rewriting to match the language idioms.

            This helps to eliminate human error during the first one so new bugs don't creep in there.
            Nice to see someone else gets it. Yeah, this isn't a magic solution for taking C code and turning it into perfectly-written bug-free idomiatic Rust. It's simply about automating the first step of a translation process - to take a C codebase, and express the same logic in Rust.

            It won't automatically fix all the bugs - but it *will* likely find quite a lot of them, because many of those bugs will be caught either by Corrode itself, of by Corrode generating code which the Rust compiler will reject. And once done, the resulting code can be manually improved to be idomatic Rust (instead of C-in-Rust), without fear of introducing all those types of bugs which C is susceptible to, and which Rust is not.

            Comment


            • #26
              Originally posted by speculatrix View Post
              Next, a tool to convert Rust code to C for performance reasons.. write your program and test in Rust, to prove it's good, then convert to make it run fast.
              Only half kidding.
              All of the Rust performance overhead and static type checking is at compile time. The Rust runtime is as light as the one for C, which is why Rust and C are equally fast and equally memory efficient in most benchmarks.

              Comment


              • #27
                If this could help translating openssl, gpg and similar projects to rust at some point....(dream)

                Comment


                • #28
                  Originally posted by Nille View Post

                  Thats wrong. You can allow it in the local Security Settings.
                  the microsoft world it's always so naif

                  Comment


                  • #29
                    Originally posted by ssokolow View Post

                    There are two parts to translating a codebase from one language to another: Ensuring equivalent functionality, and then rewriting to match the language idioms.

                    This helps to eliminate human error during the first one so new bugs don't creep in there.
                    Precisely this. What that buys you is that you get a verbatim machine-translation of C to Rust, which you can then rig for unit-tests using Rust's frameworks before you begin to refactor towards idiomatic rust to make sure the refactoring doesn't introduce errors. Rust has far more expressivity and is underpinned by notions entirely foreign to C, so the idiomatic Rust translation requires human intelligence. There's no reasonable way to automate the conversion going in that direction; a good, idiomatic conversion would be more tractable going in the other direction, from Rust to C.

                    Comment


                    • #30
                      Originally posted by ravyne View Post
                      Precisely this. What that buys you is that you get a verbatim machine-translation of C to Rust, which you can then rig for unit-tests using Rust's frameworks before you begin to refactor towards idiomatic rust to make sure the refactoring doesn't introduce errors.
                      Yep. I've seen similar tools before to convert (e.g) COBOL to Java - but what you get is simply COBOL programs written in Java syntax, because translating idioms is a much harder problem than translating syntax. What it gives you is simply a starting point - the code is as good or bad as it was before, but you've now got access to the better tools of the new language, making it easier to improve.

                      Comment

                      Working...
                      X