Live data from Hacker News

Rust in the Linux kernel: part 2

lwn.net

21–30 of 73 posts

Re: Rust in the Linux kernel: part 2

#21
post #13

Earlier quoted context omitted.

In safe rust you cannot read uninitialized memory or variables, you cannot dereference a null or freed pointer, you can't concurrently mutate the same variable from multiple threads without locking primitives, you can't accidentally modify a variable after it has been moved out of scope - all of these things are enforced at compile time. If your code compiles, you are safe from all of these classes of bugs (outside t…

> In safe rust you cannot read uninitialized memory or variables, you cannot dereference a null or freed pointer, you can't concurrently mutate the same variable from multiple threads without locking primitives, you can't accidentally modify a variable after it has been moved out of scope - all of these things are enforced at compile time. If your code compiles, you are safe from all of these classes of bugs (outside…

> Even the most novice Rust programmer who stays in the guardrails

I think this part answers your question. A novice could produce reasonably safe Rust code by just reading a book. I’ve no experience with either language and I can safely say I’d have no idea which switches to “just flip” in the compiler and what tools I should look up to write safe C++ code.

I do know that “Learn Language X” books do not include this information so as to not overwhelm the novice.

Re: Rust in the Linux kernel: part 2

#22

[flagged]

Rust has more and nicer language features compared to c++ that you can use to make the code readable.

I wish rust had overloading and specialization though.

> I personally invested a lot of time and effort into learning C/C++ and the only new language with enough difference to come along that was worth learning was Python imho. Not sure what significant differences Rust brings that warrant throwing all that knowledge away and starting again.

Ive written a little c++ professionally along with rust. I really don't think rust is that hard to learn. Especially compared to c++, I'd be embarrassed to tell people i "know" c++ despite using it a bit. there's so much to writing c++.

I think you would be a competent rust programmer in a couple weeks, have a pretty good grasp on the language and be able to pretty much contribute to any in progress project.

You could spend a weekend going through the rust book and have a good idea of the language. I dont think I could say that to anyone about any c++ book lol

Re: Rust in the Linux kernel: part 2

#24
post #21

Earlier quoted context omitted.

> In safe rust you cannot read uninitialized memory or variables, you cannot dereference a null or freed pointer, you can't concurrently mutate the same variable from multiple threads without locking primitives, you can't accidentally modify a variable after it has been moved out of scope - all of these things are enforced at compile time. If your code compiles, you are safe from all of these classes of bugs (outside…

> Even the most novice Rust programmer who stays in the guardrails I think this part answers your question. A novice could produce reasonably safe Rust code by just reading a book. I’ve no experience with either language and I can safely say I’d have no idea which switches to “just flip” in the compiler and what tools I should look up to write safe C++ code. I do know that “Learn Language X” books do not include this…

> I think this part answers your question. A novice could produce reasonably safe Rust code by just reading a book.

That blend of comments is at best grasping at straws. How long do you think a developer stays a "novice"? Does Rust have any problem that prevents developers from learning and improving their skills as fast as any other developers do? Are all Rust projects maintained by novice and junior devs where no one at all can claim to have any senior level skills?

If that's the best argument, that's not an argument at all.

Re: Rust in the Linux kernel: part 2

#25
post #13

Earlier quoted context omitted.

In safe rust you cannot read uninitialized memory or variables, you cannot dereference a null or freed pointer, you can't concurrently mutate the same variable from multiple threads without locking primitives, you can't accidentally modify a variable after it has been moved out of scope - all of these things are enforced at compile time. If your code compiles, you are safe from all of these classes of bugs (outside t…

> In safe rust you cannot read uninitialized memory or variables, you cannot dereference a null or freed pointer, you can't concurrently mutate the same variable from multiple threads without locking primitives, you can't accidentally modify a variable after it has been moved out of scope - all of these things are enforced at compile time. If your code compiles, you are safe from all of these classes of bugs (outside…

> Your blend of comments makes it sound like no one knew or cared about these issues other than Rust fanboys.

That is a strange takeaway from my post. Of course people care, but the difference is that one language and its toolchain was designed and built specifically to avoid these bugs and one wasn't.

I have been writing C++ professionally since around 2000-2001, and have been working with Rust for about 18 months. For single threaded code, the code I write in both is about equivalent in terms of robustness and stability, but for anything multithreaded, I trust my Rust code's correctness substantially more, even with all the checkers and sanitizers enabled on my C++ codebase.

Would I choose Rust for everything? Hell no, for evolutionary and fast moving code bases like in games, C++ is plenty good enough.

For anything systems related that requires parallelism and robustness, I will 100% stick with Rust.

Re: Rust in the Linux kernel: part 2

#26

[flagged]

Most of the interest I have seen is in pursuit of security. A few sources have cited that something like 70% of vulnerabilities are rooted in memory safety issues. A language that makes it impossible to introduce 70% of the security bugs is appealing.

Java does not have memory safety issues. But it's not appealing, apparently.

So why Rust then?

Re: Rust in the Linux kernel: part 2

#28
post #7

[flagged]

Rust (without use of `unsafe`) eliminates several entire classes of bugs (including bugs that comprise the majority of security related memory safety issues) while providing performance comparable to C/C++. That is really all there is to it - it is just the better option for systems programming by almost all available metrics, and I say this as someone who has been coding C and C++ professionally for coming up on 25…

Cool, but so does Java. So why Rust advertising specifically?

Re: Rust in the Linux kernel: part 2

#29
post #26

Earlier quoted context omitted.

Most of the interest I have seen is in pursuit of security. A few sources have cited that something like 70% of vulnerabilities are rooted in memory safety issues. A language that makes it impossible to introduce 70% of the security bugs is appealing.

Java does not have memory safety issues. But it's not appealing, apparently. So why Rust then?

Java is not a systems level programming language (at least in its modern OpenJDK form)

Re: Rust in the Linux kernel: part 2

#30
post #25

Earlier quoted context omitted.

> In safe rust you cannot read uninitialized memory or variables, you cannot dereference a null or freed pointer, you can't concurrently mutate the same variable from multiple threads without locking primitives, you can't accidentally modify a variable after it has been moved out of scope - all of these things are enforced at compile time. If your code compiles, you are safe from all of these classes of bugs (outside…

> Your blend of comments makes it sound like no one knew or cared about these issues other than Rust fanboys. That is a strange takeaway from my post. Of course people care, but the difference is that one language and its toolchain was designed and built specifically to avoid these bugs and one wasn't. I have been writing C++ professionally since around 2000-2001, and have been working with Rust for about 18 months.…

[flagged]
Post reply on HN