Announcement

Collapse
No announcement yet.

Jamey Sharp On Whether You Should Translate Your Code To Rust

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

  • Jamey Sharp On Whether You Should Translate Your Code To Rust

    Phoronix: Jamey Sharp On Whether You Should Translate Your Code To Rust

    Often times whenever mentioning a new security vulnerability in any piece of open-source/Linux software, it generally gets brought up in our forums "they should write that software in Rust" or similar comments about how XYZ project should see a rewrite in Rust for its memory-safety features. But is it really worthwhile porting your codebase to Rust?..

    Phoronix, Linux Hardware Reviews, Linux hardware benchmarks, Linux server benchmarks, Linux benchmarking, Desktop Linux, Linux performance, Open Source graphics, Linux How To, Ubuntu benchmarks, Ubuntu hardware, Phoronix Test Suite

  • #2
    My 2c here. General answer is: No - do not rewrite

    have a quick read here: https://en.wikipedia.org/wiki/Rewrite_(programming)

    I think Mozilla are doing it right where they are shipping some new components written in rust and eventually moving everything to it.

    With the plethora of existing testing tools (AFL, unit testing etc) your non trivial project would benefit for more use of these.

    Now, when it comes to the choice of language for your new projects... go for it! just make sure that whatever language you choose to write with has a decent following over many years so you do not end up with a legacy project in an esoteric language

    Comment


    • #3
      Originally posted by boxie View Post
      My 2c here.
      My 1.5 c:
      Your program will also likely depend on other libraries, you'll either need Rust-wrappers, and write your own where they don't yet exist, or use the libs directly thru unsafe {}.
      If there's any or much stuff that doesn't have (good) rust wrappers it might not be worth writing your new app in Rust because of the bad balance of the pros vs cons.

      I'm learning Rust but I found this to be the worst problem. No mature wrappers - no new rust app for me. Qt5 doesn't have mature wrappers either.
      Last edited by cl333r; 03 January 2017, 11:42 PM.

      Comment


      • #4
        This post will likely incite verbal violence shortly hereafter. I'm just surprised that it hasn't happened already. Basically, any time there's the question of a rewrite posed for a project, it's never about rewriting the entire project all at once. It's typically only a section of code at a time. Take one C file, rewrite it in Rust, then update your Makefile to build the Rust object with rustc or cargo and link it as if it were any other C project's object file. This is especially true of any code that's particularly vulnerable or troublesome to maintain (ie: multithreaded codepaths).

        Originally posted by cl333r View Post
        My 1.5 c:
        Your program will also likely depend on other libraries, you'll either need Rust-wrappers, and write your own where they don't yet exist, or use the libs directly thru unsafe {}.
        If there's any or much stuff that doesn't have (good) rust wrappers it might not be worth writing your new app in Rust because of the bad balance of the pros vs cons.

        I'm learning Rust but I found this to be the worst problem. No mature wrappers - no new rust app for me.
        No mature wrappers? There's a library for pretty much everything I need. Hasn't stopped me. GTK3 support is stellar. Full support for GTK 3.22 functionality.

        Qt5 doesn't have mature wrappers either.
        It's the same story with every programming language that isn't C++. Supporting C++ libraries is hard, especially Qt's entire framework. I think we should work on developing a new GUI toolkit written in Rust rather than pursuing Qt support. The plus side of a GUI toolkit written in Rust is that it would be super portable to every programming language in existence that can interface with C. So, you shouldn't fault any language for not having good wrappers for Qt.

        Comment


        • #5
          Originally posted by mmstick View Post
          Basically, any time there's the question of a rewrite posed for a project, it's never about rewriting the entire project all at once. It's typically only a section of code at a time. Take one C file, rewrite it in Rust, then update your Makefile to build the Rust object with rustc or cargo and link it as if it were any other C project's object file. This is especially true of any code that's particularly vulnerable or troublesome to maintain (ie: multithreaded codepaths).
          That is an overly simplistic view. The way to do it would be a feature at a time. preferably a new feature for the first few.

          but if your code is less than perfectly architected (and let's face it, this is most code that has been around for a while) then you are going to be refactoring more than just one part of the code base at a time.


          Comment


          • #6
            Seriously why Rust?

            In any event if you want bleeding edge language technology why not consider Swift. Yes I know it is form Apple but it has a lot of good features and frankly there is a lot of interest and rapid growth. You of course end up with the same lack of mature libraries issue but at least there are big names (IBM and others) building out the infrastructure on Linux. I just don't see Rust getting the wide cross platform acceptance due other lack of a Shepard to help the language out.

            Comment


            • #7
              Originally posted by wizard69 View Post
              In any event if you want bleeding edge language technology why not consider Swift.
              As far as I’m concerned, that lost crucial momentum, and community goodwill, when Apple issued all those takedowns before changing their minds and open-sourcing it.

              Comment


              • #8
                Originally posted by mmstick View Post
                The plus side of a GUI toolkit written in Rust is that it would be super portable to every programming language in existence that can interface with C.
                That's unture unless you constrain the GUI toolkit's API to something supported by "extern C" -- in which case, why bother with a new toolkit, "just" use e.g. Gtk which is already written and "just" needs an API wrapper. Otherwise, you're facing exactly the same problem as Qt5 -- namely that basically no FFIs support "extern C++" (or "extern Rust" in this case).
                Last edited by fabdiznec; 04 January 2017, 03:28 AM.

                Comment


                • #9
                  Rust???

                  It's 2017, why is anyone still wasting time talking about failed languages like Rust?

                  The only thing Rust succeeded at was becoming the new D. A niche and irrelevant language with a tiny group of deadenders spamming forums desperately trying to hype some magical bullet points that have no real world benefits.

                  C++ exploded in adoption and became the dominant systems and application programming language because the benefits over raw C code were immediate and obvious to any professional software engineer.

                  Rust utterly failed to make its case and instead

                  Comment


                  • #10
                    Originally posted by BeardedGNUFreak View Post
                    Rust???

                    It's 2017, why is anyone still wasting time talking about failed languages like Rust?

                    The only thing Rust succeeded at was becoming the new D. A niche and irrelevant language with a tiny group of deadenders spamming forums desperately trying to hype some magical bullet points that have no real world benefits.

                    C++ exploded in adoption and became the dominant systems and application programming language because the benefits over raw C code were immediate and obvious to any professional software engineer.

                    Rust utterly failed to make its case and instead
                    The post is incomplete.
                    Too much rage broke your keyboard?

                    Comment

                    Working...
                    X