Announcement

Collapse
No announcement yet.

The Latest Progress On Rust For The Linux Kernel

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

  • The Latest Progress On Rust For The Linux Kernel

    Phoronix: The Latest Progress On Rust For The Linux Kernel

    While the Rust programming language support for usage within the kernel isn't landing for the Linux 5.15 merge window ending this weekend, that effort remains ongoing. A status update on the effort was shared this week about Rust usage for the Linux kernel...

    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
    Does this mean totally replacing the build system with a more complicated one (and/or placing it on top of the current one) just to allow a few thousand lines of Rust code in the kernel? Turning the kernel into a crate......

    Personally I have a hard time writing Rust code. Not because of the need to check everything, but because the language has a terrible syntax...
    I took years to understand C++ (mostly because it was my first language and I was narrow-minded enough to not look at templates, lambdas, the huge standard library and other advanced features), a month to understand C, four months to understand Java, five months to understand JavaScript (this sure is a messy language as well).... but Rust? I guess I will never understand it.
    Last edited by tildearrow; 11 September 2021, 05:05 PM.

    Comment


    • #3
      Originally posted by tildearrow View Post
      Does this mean totally replacing the build system with a more complicated one (and/or placing it on top of the current one) just to allow a few thousand lines of Rust code in the kernel? Turning the kernel into a crate......
      First, using rust doesn't mean they will use cargo... cargo isn't a need part to run rust, I am pretty sure kernel devs are not gonna use cargo and crates, kernel land isn't std so 90% of crates for rust are useless anyway.
      Originally posted by tildearrow View Post
      Personally I have a hard time writing Rust code. Not because of the need to check everything, but because the language has a terrible syntax in where sometimes it's *, sometimes it's ?, sometimes you put &, sometimes you put mut, what the heck is ', does it go like this or that...
      Really? Really?! Sorry but you wasn't writing Rust code, you clearly haven't spend even 5 minutes to learn it basics. You don't even know the basic from using pointers in C!!! If you would have that you would get at least half of your "sometimes".

      Comment


      • #4
        Originally posted by dragonn View Post

        First, using rust doesn't mean they will use cargo... cargo isn't a need part to run rust, I am pretty sure kernel devs are not gonna use cargo and crates, kernel land isn't std so 90% of crates for rust are useless anyway.
        In the slides, kernel is a crate. So this means something.

        Originally posted by dragonn View Post
        Really? Really?! Sorry but you wasn't writing Rust code, you clearly haven't spend even 5 minutes to learn it basics. You don't even know the basic from using pointers in C!!! If you would have that you would get at least half of your "sometimes".
        You know what I spent HOURS learning the language and trying to write on it. I was exploding at the window by the time I got off my machine.
        I don't feel like this when writing code in other languages (even C which is extremely simple but hard to master!!!).

        Even if I spent more time to learn about the language and actually produce something bigger, I would take much longer and be less productive than with another language.
        I will come back in a month and tell you how I felt after learning and writing another Rust program, and I hopefully will prove my point.
        Last edited by tildearrow; 11 September 2021, 03:26 PM.

        Comment


        • #5
          Originally posted by tildearrow View Post

          In the slides, kernel is a crate. So this means something.
          Thats only a naming-scheme in Rust, in C you have libraries with you import, in Rust you have crates. When programming kernel modules in C you also import some tools provided by the kernel.

          Originally posted by tildearrow View Post

          You know what I spent HOURS learning the language and trying to write on it. I was exploding at the window by the time I got off my machine.
          Yeah.. then you would really get what are *, &, mut are, that is really like reading the basics docs for 15 minutes, they only new thing are ' and I get they can be a bit hard.
          Originally posted by tildearrow View Post
          (even C which is extremely simple but hard to master!!!).
          That is exactly the problem with C! It might feel simple at the start for a beginner but then you get buffer overflows, null pointer errors, SIGSEG, race conditions.
          Rust has a stepper learning curve because it prevents your from doing all those errors when writing you code and not spending hours on debugging C because you get a
          weird race conditions.
          Originally posted by tildearrow View Post
          Even if I spent more time to learn about the language and actually produce something bigger, I would take much longer and be less productive than with another language.
          Yes, writing programs in Rust takes a longer time when you only count the how much time you spend on writing the code. But when you account for all test, getting all bugs out etc. the whole picture can change dramatically.
          Last edited by dragonn; 11 September 2021, 03:32 PM.

          Comment


          • #6
            Originally posted by tildearrow View Post

            In the slides, kernel is a crate. So this means something.



            You know what I spent HOURS learning the language and trying to write on it. I was exploding at the window by the time I got off my machine.
            I don't feel like this when writing code in other languages (even C which is extremely simple but hard to master!!!).

            Even if I spent more time to learn about the language and actually produce something bigger, I would take much longer and be less productive than with another language.
            I will come back in a month and tell you how I felt after learning and writing another Rust program, and I hopefully will prove my point.
            I've spent months learning Rust and the start was similar. Especially since this was before v1.0 I had to use try! macro and other old style uglyness. But now, when I write in ANY other imperative language, I feel dirty. It feels like going from a Tesla car to some ancient black cloud spewing diesel car from the eastern block.

            Even "safe" languages like Go have this, at minimum nulls at worst race conditions. As soon as you get into something more serious it shows up really quick. Embedded space even more.

            You can probably see that I'm very much a Rust fanboy, but with 20+ years of programming experience, C, C++, Pascal, Assembly and more I can tell you Rust really moved the bar, basically after 30 years of it not moving at all.

            As for the bigger projects and time, I did some bigger stuff alone, and it worked out nicely. Rust saves you a huge amount of time by forcing a good data ownership model from the start. You find the cul-de-sacs very early, because they'll show up as compiler errors. Once you start thinking in the way that Rust does about data tho it all goes away with the occasional "ahhh right, I can't coz it'd get freed here beforehand".

            Comment


            • #7
              Originally posted by Almindor View Post
              I've spent months learning Rust and the start was similar. Especially since this was before v1.0 I had to use try! macro and other old style uglyness. But now, when I write in ANY other imperative language, I feel dirty. It feels like going from a Tesla car to some ancient black cloud spewing diesel car from the eastern block.
              With Rust I have conflicting emotions. On one hand it certainly catches a lot of errors early. On the other hand, I feel as if the language constrains me too much. I concede that this is heavily influenced by my inexperience with the language, but the feeling that it is too complicated for what it provides is similar to what I feel with Java and C++.

              This is why I'm a lot more hyped with Zig: it is a lot simpler and although it doesn't catch as much errors as Rust at compile time, I feel that the language is helping me, not hindering me.

              Disclaimer: Running the unit tests of my C programs using valgrind has made C a lot friendlier for me... and Rust has to be able to one-up that. What I'm looking for is not (only) a static-typed compiled programming language that catches more errors, I want one that also makes me as productive as with dynamic/interpreted languages.

              Comment


              • #8
                Originally posted by tildearrow View Post
                Does this mean totally replacing the build system with a more complicated one (and/or placing it on top of the current one) just to allow a few thousand lines of Rust code in the kernel? Turning the kernel into a crate......

                Personally I have a hard time writing Rust code. Not because of the need to check everything, but because the language has a terrible syntax in where sometimes it's *, sometimes it's ?, sometimes you put &, sometimes you put mut, what the heck is ', does it go like this or that...
                I took years to understand C++ (mostly because it was my first language and I was narrow-minded enough to not look at templates, lambdas, the huge standard library and other advanced features), a month to understand C, four months to understand Java, five months to understand JavaScript (this sure is a messy language as well).... but Rust? I guess I will never understand it.
                It doesn't sound like the problem is that the language has a difficult syntax, it sounds like it is you who not understand it.

                The * character is used for destructuring an object. Kind of like [...stuff] in JavaScript.
                The mut keyword is used to declare that a variable or parameter is to be mutable.
                The & character is used to declare that you want the argument to be passed as a reference. Like the ref keyword in C#.

                Comment


                • #9
                  I’m trying to learn rust. It’s challenging. It also challenges my hardware, which is the main reason I’m not pursuing it. When I get past hello world and into a more realistic project, I start having problems compiling – running out of memory it slows to a crawl and the cpu gets pretty overloaded. It either crashes or it takes an hour or so to compile. Sure, I need to upgrade. Can I afford it? No. I don’t have this issue with clang, so I’ll stick to c.

                  My question is how many other’s experience this, and will this slow down rust contributions?

                  Comment


                  • #10
                    Originally posted by darkoverlordofdata View Post
                    I’m trying to learn rust. It’s challenging. It also challenges my hardware, which is the main reason I’m not pursuing it. When I get past hello world and into a more realistic project, I start having problems compiling – running out of memory it slows to a crawl and the cpu gets pretty overloaded. It either crashes or it takes an hour or so to compile. Sure, I need to upgrade. Can I afford it? No. I don’t have this issue with clang, so I’ll stick to c.

                    My question is how many other’s experience this, and will this slow down rust contributions?
                    What is you hardware? It is true that compiling rust can be really resource intensive, probably because how much more the compile keeps track off compared to other langs.

                    Comment

                    Working...
                    X