Originally posted by mdedetrich
View Post
Announcement
Collapse
No announcement yet.
Linux's V4L2 VP9 Codec Kernel Code Rewritten In Rust For Better Memory Safety
Collapse
X
-
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.
- Likes 2
Comment
-
Originally posted by uid313 View PostI 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.
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.
- Likes 1
Comment
-
Originally posted by Volta View PostMaybe partially. It's not Rust in user space and Linus explained why kernel is different.
C has at least two great and mature compilers and it's very stable language.
Rust code written last year may be obsolete now.
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:
Its complexity is still growing.
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 PostFunctions 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.
And C for loops are usually far easier to reason about than all the junk in Rust or C++ iterators bullshit.
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.
- Likes 6
Comment
-
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.
- Likes 3
Comment
-
Originally posted by sobrus View PostRust 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).
Yes, steep learning curve, but a lot of genuinely useful goodies at the end.
Comment
-
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.
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.
- Likes 1
Comment
-
Originally posted by Weasel View PostThe point is: it depends on the function. RTFM. Skill issue.
Sadly, the compiler doesn't detect documentation changes. This is where a proper type system becomes important.
- Likes 5
Comment
-
Originally posted by pabloski View Post
Yeah so stable that undefined behaviours and an incomplete programming model are there after 50 years
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!!
- Likes 1
Comment
Comment