Announcement

Collapse
No announcement yet.

Linux's V4L2 VP9 Codec Kernel Code Rewritten In Rust For Better Memory Safety

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

  • #31
    Originally posted by mdedetrich View Post

    Rust's linear type system which is how it tracks memory access has been formally verified so you may be waiting for a while. That said, there may be issues in the backends (i.e. llvm/gcc) but that isn't Rust's fault and C is in the exact same boat in that regard.

    Fun fact, as Rust has been developed over time it has actually revealed many bugs within LLVM especially when it comes to aliasing.
    "Even in perfect language you can write buggy/bad code"

    Comment


    • #32
      Originally posted by Volta View Post

      What's so amazing? Rust is far from maturity of C and code written in Rust is much harder to read and follow IMO. I'm waiting for large project written in Rust to see if it's really capable of replacing C. So far there are only tiny projects which are doing simple tasks. I'd love to see PostgreSQL equivalent. It's so much hype and promises about Rust, but nothing interesting to see so far. The order should be different.


      Do that in Rust, I dare you.

      Comment


      • #33
        Originally posted by uid313 View Post
        I think Rust is easier to follow than C.

        In C when I look at a function signature I have no idea if the return value or any of its arguments can be null, while in Rust it is apparent from the Option type.

        In C a function might return the value -1, if it does that is quite surprising and unexpected, furthermore I don't really know what it means even though I can guess it is some kind of error. In Rust this will never be a surprise as a function will return the Result<T, E> type which tells me there can be an error and gives me an enum to figure out what the problem is.

        In Rust the loop will be a simple foreach loop, but in C the index can start on 0 or 1 or something else, and it can be i++, i--, ++i, or --i or something else confusing.
        Functions can return whatever the hell they want. Ever heard of API contracts and documentation? Even if it returns -1 or NULL, how do you even know what it means? Maybe it's not even an error but an optional return type.

        The point is: it depends on the function. RTFM. Skill issue.

        And C for loops are usually far easier to reason about than all the junk in Rust or C++ iterators bullshit.

        Comment


        • #34
          Originally posted by Volta View Post
          Maybe partially. It's not Rust in user space and Linus explained why kernel is different.
          What do you mean with partially? And what has Linus and user space to do with it?

          C has at least two great and mature compilers and it's very stable language.
          You mean stable as in nothing changes much? You could forever use rust 1.0 if you see any benefit in that.

          Rust code written last year may be obsolete now.
          Why are you making up claims when you clearly have never even bothered to read about it?


          Not sure if any compiler still fully supports K&R and if it's possible to wildly mix it with C99?

          It seems it's not so obvious:
          what does this say about readability?

          Its complexity is still growing.
          Are you really to lazy to read what you post? It says that some people have worries that it might become more complex. But I see, you mainly search the internet for something bad in rust without even understanding what it's about.
          You know that there are enough valid critic points to rust? I'm not gonna tell you, take a little effort for your trolling.

          Originally posted by Weasel View Post
          Functions can return whatever the hell they want. Ever heard of API contracts and documentation? Even if it returns -1 or NULL, how do you even know what it means? Maybe it's not even an error but an optional return type.
          That was exactly his argument, you don't need the documentation because its obvious from the code if it returns a value or an error in rust.

          And C for loops are usually far easier to reason about than all the junk in Rust or C++ iterators bullshit.
          What's hard to reason about iterating over a collection of values? What do you think the i++ in your for loop stands for?
          ​Was your argument that a ton of boilerplate is easier to read? You would be pretty alone with that I guess.
          Last edited by Anux; 28 February 2024, 11:30 AM.

          Comment


          • #35
            Rust is harder at first, because it deviates from old Pascal/BCPL/C/C++/Java/C# school.
            Especially ownership may be hard to follow at first, since it's not explicitly visible at first sight, and will cause a lot of compilation errors
            And it's not object oriented (at least says so, just like go)

            BUT
            - I've not touched C++ for like 15 years already and when I saw modern C++ the first thought was "oh my, I'm not touching this, I'd rather go rust". This is nowhere as simple as Pascal or C used to be.
            - memory safety is by design, so unless there is error in the compiler, you may have hard time finding memory related security bugs in your code. The compiler will not compile your code if you don't follow the rules.
            - rust compiler is written in rust
            - Rust compiler will always explain what the error is all about, and even tell you how to fix it. just read the error message!
            - Rust is fully backwards compatible. There are no plans for any Rust 2. Even if you try to compile 40 year old program, cargo will download all the 40 year old dependencies and build it for you. Try to do it with python... You will be not allowed to use 40 year old library in your new app, but the packages will be there (at https://crates.io/) for legacy code. Every single version. If a new library version is released during developement, and it's not working for you, you can stick with the old one. Anyone will be able to compile it anyway.


            Seriously, even if it is intimidating at first, there's a lot to like in Rust. Go is nice too, but with a few "gotchas"
            I'd rather use any of them than C/C++ nowadays. But for low level programming, rust is the way to go (pun intended).
            Last edited by sobrus; 28 February 2024, 12:18 PM.

            Comment


            • #36
              Originally posted by sobrus View Post
              Rust is harder at first, because it deviates from old Pascal/BCPL/C/C++/Java/C# school.
              Especially ownership may be hard to follow at first, since it's not explicitly visible at first sight, and will cause a lot of compilation errors
              And it's not object oriented (at least says so, just like go)

              BUT
              - I've not touched C++ for like 15 years already and when I saw modern C++ the first thought was "oh my, I'm not touching this, I'd rather go rust". This is nowhere as simple as Pascal or C used to be.
              - memory safety is by design, so unless there is error in the compiler, you may have hard time finding memory related security bugs in your code. The compiler will not compile your code if you don't follow the rules.
              - rust compiler is written in rust
              - Rust compiler will always explain what the error is all about, and even tell you how to fix it. just read the error message!
              - Rust is fully backwards compatible. There are no plans for any Rust 2. Even if you try to compile 40 year old program, cargo will download all the 40 year old dependencies and build it for you. Try to do it with python... You will be not allowed to use 40 year old library in your new app, but the packages will be there (at https://crates.io/) for legacy code. Every single version. If a new library version is released during developement, and it's not working for you, you can stick with the old one. Anyone will be able to compile it anyway.


              Seriously, even if it is intimidating at first, there's a lot to like in Rust. Go is nice too, but with a few "gotchas"
              I'd rather use any of them than C/C++ nowadays. But for low level programming, rust is the way to go (pun intended).
              Amen to that.
              Yes, steep learning curve, but a lot of genuinely useful goodies at the end.

              Comment


              • #37
                Originally posted by Volta View Post

                I'm talking about database and you're showing me this? Show me a big project where scalability and memory management have huge impact on performance.
                Just in the news:

                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


                It's not big compared to postgres or the other repos I mentioned before in this thread, but I would argue that scalability and memory management are important here.

                Comment


                • #38
                  Originally posted by Weasel View Post
                  The point is: it depends on the function. RTFM. Skill issue.
                  Trouble happens when people change the meaning of the function, documentation is updated but not all places the function is used are correctly updated.
                  Sadly, the compiler doesn't detect documentation changes. This is where a proper type system becomes important.


                  Comment


                  • #39
                    Originally posted by pabloski View Post

                    Yeah so stable that undefined behaviours and an incomplete programming model are there after 50 years
                    Stable in different meaning. I thought it will be obvious?

                    No because (1) deprecation is a slow process, (2) Rust can mix and match code written for various versions of the language, (3) the latest and greatest compiler is forced to implement the old and even deprecated bits. It is the only language where you can take a crate unmantained since forever and use in your newly written code!!
                    In this case by 'deprecation' I meant: newer and better things arrived.

                    Comment


                    • #40
                      Oh boy…..

                      Biden administration calls for developers to embrace memory-safe programing languages and move away from those that cause buffer overflows and other memory access vulnerabilities.

                      Comment

                      Working...
                      X