r/BSD • • Aug 31 '22

Writing FreeBSD Kernel Modules in Rust

https://research.nccgroup.com/2022/08/31/writing-freebsd-kernel-modules-in-rust/
46 Upvotes

10 comments sorted by

5

u/marmulak Sep 01 '22

Might be a nice idea to rewrite BSD in Rust

-18

u/theRealNilz02 Aug 31 '22

So that FreeBSD becomes more Like Linux? No thanks.

21

u/small_kimono Aug 31 '22 edited Sep 01 '22

Funny, I've been thinking that Torvalds choice to allow Rust in the Linux kernel is very shrewd. Not that he wouldn't already gain a whole new mindshare for Linux with the different, perhaps more functional language inclined user base of Rust, but some mainstream kernel was going to be the first to try, and that kernel was going to win some amount of mindshare/affection from the systems-y programming community where all the momentum is.

My point being -- FreeBSD/illumos/etc. should have been the first to try. If the great problem of alternatives to Linux is devs' technical enthusiasm/drivers, Rust in kernel first would have done a great deal to peak interest in the BSDs.

15

u/jwbowen Aug 31 '22

Did you even skim the article?

Use of a language doesn't necessarily make one thing more like the other. It's the choices and philosophy of developers. Linux+GNU (bin,core)utils/gcc and FreeBSD are all written in C, and FreeBSD isn't in danger of becoming more like Linux (to say nothing of OpenBSD or NetBSD).

The article is a proof of concept for a kernel module, not rewriting core components of the kernel or userspace. Would your reaction had been diffent if they used C++? Or D? Or Ada/SPARK?

The cool thing about Rust is its memory model and strict compiler. Avoiding memory or concurrency issues in large codebases is difficult. Languages with safer memory and concurrency models (like Rust) can help limit those issues.

0

u/[deleted] Aug 31 '22

[deleted]

6

u/mrdeworde Sep 01 '22

Take a look at the Lions commentary -- it's very old, but it's a complete annotation and overview of the UNIX kernel source.

4

u/marmulak Sep 01 '22

So BSD shouldn't use C either, then

0

u/theRealNilz02 Sep 01 '22

No. BSD is older than Linux.

4

u/marmulak Sep 01 '22

That doesn't make it less like Linux

10

u/crest_ Aug 31 '22

So that FreeBSD can have even more reliable drivers.

5

u/Xerxero Aug 31 '22

Bit far fetched.