Live data from Hacker News

Rust in the Linux kernel: part 2

lwn.net

71–73 of 73 posts

Re: Rust in the Linux kernel: part 2

#71
post #68
post #67

Earlier quoted context omitted.

For what it’s worth, the Rust driver pointed to in the article doesn’t have a single unsafe block, raw pointer, pointer arithmetic, or any of those other things you mentioned. It’s a simple driver. But it’s also possible that rust code doesn’t necessarily have to copy the C code line for line - the C way of doing things with pointer arithmetic may just not be necessary with the abstractions rust provides.

It's basically a "Hello, World" type of driver. A "Hello, World" in C or Rust typically also doesn't involve unsafe blocks or safety issues.

In Rust you know there is no memory issue because there is no unsafe block. In C you don't know if there is no memory issue, there are many way to write a hello world that has memory issue.

    char hello[5] = "Hello";
Oops, forgot the \0, memory issue when printing that string.

Even complex driver in rust will have very little amount of unsafe because of correct use of (often zero cost) abstractions. And it is much less mental drain to check only that, than when every single line is a minefield that could hide undefined behavior

Re: Rust in the Linux kernel: part 2

#72

>The next article in this series will look at the design of the interface between the C and Rust code in the kernel, as well as the process of adding new bindings when necessary. This is the actual useful one since so little of the kernel has Rust bindings. When I tried to implement a filesystem driver in rust I spent most of my time trying to write bindings instead of trying to write a filesystem.

Did you try bindgen? Because it’s extremely good and efficient imo.

Re: Rust in the Linux kernel: part 2

#73
post #45
post #38

Earlier quoted context omitted.

Sun tried out allowing Java in the kernel, it could be used to write device drivers just as Rust is being used now.

How would that even work with the JVM?

Probably https://en.m.wikipedia.org/wiki/Jazelle or similar would be the answer.
Post reply on HN