Live data from Hacker News

Rewrite Linux Kernel in Rust?

dominuscarnufex.github.io

31–40 of 133 posts

Re: Rewrite Linux Kernel in Rust?

#31

What is the rust communities obsession with suggesting (threatening?) rewrites of battle tested C programs that have been around for decades? Now a kernel for a new OS, that'd be something.

The article covers both of your points:

> Rust is supposed to be an excellent systems programming language, having the ability to go extremely close to the bare metal, while offering a thick layer of security and expressiveness which C lacks of. And such an assumption has to be trialled!

> Which Philipp Oppermann has already done by beginning to write a real OS in Rust and writing about it. But this is not a realistic trial: an OS starting from scratch has almost zero chance to end up being finished, not to mention being actually used on real machines.

That is, a more accurate title might be "Proof of concept of incrementally rewriting the Linux kernel in Rust".

Re: Rewrite Linux Kernel in Rust?

#32
post #23

Earlier quoted context omitted.

Yeah it's always great to see concepts implemented and working. My favorite similar project I would use as an argument to bring Nim into a legacy C codebase is https://github.com/ckkashyap/nimxv6 which started off by taking the xv6 kernel and replacing uart.c with uart.nim. Every step of the way you can test your translation was correct, and once you have Nim in the build process you can start using it for new things…

Do you get anything with him? I was under the impression dereference safety wasn't a priority.

Debatedly, you get a better stdlib and some usability features.

Re: Rewrite Linux Kernel in Rust?

#33
post #22

Earlier quoted context omitted.

I'll grant that, but it's a programming language, so I kind of expect it to follow the order assignment does when I write in C++, C#, etc.

> I kind of expect it to follow the order assignment does when I write in C++, C#, etc. There is no special precedence that should be applied to C. Similarity to C only imparts benefits to those that are fimilar with C-like languages or variants that follow that structure. That ends up being a lot of people because of how popular C and variants have been, but that's doesn't inherently make it better . It's sort of a…

This does raise the question: which languages other than AT&T assembly put the value first?

Re: Rewrite Linux Kernel in Rust?

#34
post #23

Earlier quoted context omitted.

Yeah it's always great to see concepts implemented and working. My favorite similar project I would use as an argument to bring Nim into a legacy C codebase is https://github.com/ckkashyap/nimxv6 which started off by taking the xv6 kernel and replacing uart.c with uart.nim. Every step of the way you can test your translation was correct, and once you have Nim in the build process you can start using it for new things…

Do you get anything with him? I was under the impression dereference safety wasn't a priority.

People tell me it's as readable as Python, has macros, compiles to efficient C (among others), and is easier to learn than Rust esp since it's GC'd. These are good reasons to use it for many apps. I put it in Go's category mostly. However, I think affine types (Rust's advantage) could be added to it or a safety-critical subset.

Re: Rewrite Linux Kernel in Rust?

#35
post #23
post #9

Without making any assertions as to the benefits or problems of integrating Rust into the Linux kernel to replace components, I just want to point out it's really cool that you can and that someone has gone through the trouble of documenting how. That's just awesome. Discussion about whether this is a good idea or not, and the problems of doing so, can now commence in earnest, and without the pesky problem of it bein…

Yeah it's always great to see concepts implemented and working. My favorite similar project I would use as an argument to bring Nim into a legacy C codebase is https://github.com/ckkashyap/nimxv6 which started off by taking the xv6 kernel and replacing uart.c with uart.nim. Every step of the way you can test your translation was correct, and once you have Nim in the build process you can start using it for new things…

I ended up doing that for the netcode.io port of Rust and it worked out really well. Both in stubbing out implementations and in calling C API from Rust until I had 100% Rust implementation.

Re: Rewrite Linux Kernel in Rust?

#36
post #10

This is an interesting idea, but probably won't work out because Linus (and other developers) may not want to transition away from the C language (see Linus's comments about not using C++.) I think it would be excellent to see Rust being used, but the implementation of replacing C with Rust could be very complicated, and Rust's benefits may not be directly visible when having to port/rewrite a lot of the components.

Rust doesn't have downsides of C++ by design.

Re: Rewrite Linux Kernel in Rust?

#37
post #10

This is an interesting idea, but probably won't work out because Linus (and other developers) may not want to transition away from the C language (see Linus's comments about not using C++.) I think it would be excellent to see Rust being used, but the implementation of replacing C with Rust could be very complicated, and Rust's benefits may not be directly visible when having to port/rewrite a lot of the components.

And GNU Herd weren't on board with creating a monolithic kernel.

So what? It got built.

Re: Rewrite Linux Kernel in Rust?

#38
post #10

This is an interesting idea, but probably won't work out because Linus (and other developers) may not want to transition away from the C language (see Linus's comments about not using C++.) I think it would be excellent to see Rust being used, but the implementation of replacing C with Rust could be very complicated, and Rust's benefits may not be directly visible when having to port/rewrite a lot of the components.

If there were a fork and the fork were to gain momentum it might be not be up to Linus.

A project like this might attract new developers because it might be less intimidating than joining the Linux kernel proper. There would also be the attraction of learning Rust in a very real world context.

edit:s/in/it

Re: Rewrite Linux Kernel in Rust?

#39

Pretty cool. I decided to take a similar path in trying to improve/ensafen parts of the BEAM VM by finding small chunks I could rewrite in Rust from C. Most of the headache was build toolchain integration stuff. I did manage to get a few simple things slotted in that appear to work transparently, which made me hopeful for future more complicated things to play with like new process mailbox implementations, etc. Anywa…

That sounds like another nice idea.

What happened to your project?

Re: Rewrite Linux Kernel in Rust?

#40

Pretty cool. I decided to take a similar path in trying to improve/ensafen parts of the BEAM VM by finding small chunks I could rewrite in Rust from C. Most of the headache was build toolchain integration stuff. I did manage to get a few simple things slotted in that appear to work transparently, which made me hopeful for future more complicated things to play with like new process mailbox implementations, etc. Anywa…

That sounds like another nice idea. What happened to your project?

Ongoing, but BEAM is no longer part of my day job (though Rust is), so it's slower going and only moves occasionally forward between the hours of 12am and 3am when the rest of my family is asleep.
Post reply on HN