r/linux • • Apr 14 '21

Kernel [RFC] Rust support in the Linux kernel

https://lkml.org/lkml/2021/4/14/1023
608 Upvotes

316 comments sorted by

View all comments

Show parent comments

5

u/[deleted] Apr 15 '21

Can you provide an example where the Rust code looks good and simple but has surprising bad behavior?

0

u/[deleted] Apr 15 '21

[deleted]

5

u/Helmic Apr 15 '21 edited Apr 16 '21

i mean, that's the point, rust's improvements come specifically from disallowing you to do things that are possible but really bad in other languages. the comparisons have to be made to make it clear what rust is bringing to the table. rust is not a flavor of ice cream where one person's subjective preference is just as valid as anyone else's, it is a tool that has specific safety measures built into it, and to clarify what those safety measures are examples need to be made of what goes wrong in langauges that do not have those safety measures.

this isn't to say that C++ doesn't still have other advantages - pretty much anyone that gets formal education in programming is taught to program in C++, a lot more people know C++ than they know Rust. C++'s overwhelming popularity comes with its own host of advantages. but when trying to explain why people like rust, you can't just say "memory safety" without giving an example of why that's actually important, and C++ is the most comparable language to Rust for this purpose.

it's not like rust is otherwise doing something no other language or compiler is capable of, whose benefits need no comparisons to other langauges. it's not allowing applications to run faster than assembly while being as easy and readable as a high level language where it's hardly necessary to make any comparisions to other languages. rust does a lot of the same jobs you'd use C++ for, which is why it being brought into the krenel is a big deal. the two have to be compared, and it's natural for the newer language made to address problems with the older language to have a lot of advantages. it isn't necessarily ready yet to be a wholesale replacement of every line of C++ in the kernel, but clearly the intent is for the kernel to one day be written in something other than C++, even if that language doesn't end up being rust.