Announcement

Collapse
No announcement yet.

Corrode Making Progress On Translating C To Rust

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

  • #11
    Originally posted by kozzi11 View Post
    If you're using Windows, start by running ./fixGitSymlinksForWindows.bat as admin.
    Ok I see this like something "I am virus but I am not so good to do anything without admin access so please execute me as a admin"
    It is a script man. *.bat files are Windows's (depressingly crappy) version of shell scripts. Just open it with a text editor and use your l33t haxxor skills to make sure it isn't doing anything bad before executing it.

    dem kids these days...

    Comment


    • #12
      I don't understand, if Rust is so good, why not write Corrode in it?

      or better yet, write Corrode in C, use Corrode to convert Corrode to Rust, then check that the Rust version of Corrode converting the C source produces the same output as the C version did?

      Comment


      • #13
        Originally posted by speculatrix View Post
        I don't understand, if Rust is so good, why not write Corrode in it?
        Because, as the article explain, there is already a C parser for Haskell, but there is none for Rust.

        Comment


        • #14
          There's a lot of crappy C code out there so what will happen when it is translated? Isn't it likely that the translation will be even worse?. I really like the idea of translating to Rust but think there will be lots of problems.

          Comment


          • #15
            Originally posted by speculatrix View Post
            I don't understand, if Rust is so good, why not write Corrode in it?

            or better yet, write Corrode in C, use Corrode to convert Corrode to Rust, then check that the Rust version of Corrode converting the C source produces the same output as the C version did?
            Haskell has an established history of language parsing. The parsing libraries are the best around, so converting C source to Rust with Haskell is very simple to achieve. By choosing Haskell, work could immediately begin on actually translating parsed C code for results on day one, instead of writing a C parser in Rust.

            [QUOTE=Ronshere]There's a lot of crappy C code out there so what will happen when it is translated? Isn't it likely that the translation will be even worse?. I really like the idea of translating to Rust but think there will be lots of problems.
            [/QOTE]

            Direct translation results in a ton of uses of the unsafe keyword. Quality is more or less the same, just not up to Rust idioms. It may not compile if the C code was written in a way that violates Rust standards, which is pretty much guaranteed, but it speeds up the translation process greatly. Rewriting everything from scratch is the best approach if you want the highest quality possible code though, because that's the only way you'll be able to take advantage of better design decisions, which would require everything to be rewritten anyway.

            Comment


            • #16
              [QUOTE=mmstick;n908879]

              Haskell has an established history of language parsing. The parsing libraries are the best around, so converting C source to Rust with Haskell is very simple to achieve. By choosing Haskell, work could immediately begin on actually translating parsed C code for results on day one, instead of writing a C parser in Rust.

              Originally posted by Ronshere
              There's a lot of crappy C code out there so what will happen when it is translated? Isn't it likely that the translation will be even worse?. I really like the idea of translating to Rust but think there will be lots of problems.
              Direct translation results in a ton of uses of the unsafe keyword. Quality is more or less the same, just not up to Rust idioms. It may not compile if the C code was written in a way that violates Rust standards, which is pretty much guaranteed, but it speeds up the translation process greatly. Rewriting everything from scratch is the best approach if you want the highest quality possible code though, because that's the only way you'll be able to take advantage of better design decisions, which would require everything to be rewritten anyway.

              Comment


              • #17
                [QUOTE=mmstick;n908880]
                Originally posted by mmstick View Post

                Haskell has an established history of language parsing. The parsing libraries are the best around, so converting C source to Rust with Haskell is very simple to achieve. By choosing Haskell, work could immediately begin on actually translating parsed C code for results on day one, instead of writing a C parser in Rust.



                Direct translation results in a ton of uses of the unsafe keyword. Quality is more or less the same, just not up to Rust idioms. It may not compile if the C code was written in a way that violates Rust standards, which is pretty much guaranteed, but it speeds up the translation process greatly. Rewriting everything from scratch is the best approach if you want the highest quality possible code though, because that's the only way you'll be able to take advantage of better design decisions, which would require everything to be rewritten anyway.
                Is it possible to use Haskell code into Rust?

                This means to me that translating C to Rust is useless, because in order to make the best advantage of Rust language you should rewrite the code. Am I right?

                Comment


                • #18
                  Originally posted by timofonic View Post
                  This means to me that translating C to Rust is useless, because in order to make the best advantage of Rust language you should rewrite the code. Am I right?
                  Well it is not useless, if I understand things correctly. If you read about this Corrode, one of the purposes is to take care of some old unmaintaned code - which hardly anyone cares about thus it WON'T ever get rewritten. But by translating it to rust semi-automatically you can then use Rust compiler checks to eliminate some security bugs - which otherwise would persist for years - and possibly maintain it easier as Rust is meant to speedup coding compared to C...

                  Comment


                  • #19
                    Originally posted by timofonic View Post
                    This means to me that translating C to Rust is useless, because in order to make the best advantage of Rust language you should rewrite the code. Am I right?
                    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.

                    Comment


                    • #20
                      Originally posted by timofonic View Post

                      Is it possible to use Haskell code into Rust?

                      This means to me that translating C to Rust is useless, because in order to make the best advantage of Rust language you should rewrite the code. Am I right?
                      There does exist a large range of usefulness in between "totally useless" and "100% perfect for all uses".

                      You may not personally be interested in automatically transforming large legacy C codebases to Rust, but other people are. I certainly don't think anyone would recommend starting a new project in C if you were always planning to convert to Rust later on.

                      Comment

                      Working...
                      X