3 ms·
I'm a big fan of Rust, used it for several projects already, loved it. Too bad much of the systems programming is currently tied to C/C++ infrastructure. There
by the_grue 9y ago
I'm a big fan of Rust, used it for several projects already, loved it. Too bad much of the systems programming is currently tied to C/C++ infrastructure. There is only so far you can get with FFI. Most likely not far enough to write a Linux kernel driver and many other things, unfortunately. Here's hoping the situation changes now that Rust is attracting so much attention.
- ethelward 9y ago> Most likely not far enough to write a Linux kernel driver Well... https://github.com/saschagrunert/kmod https://github.com/saschagrunert/kmod
- the_grue 9y agoHeh, but it doesn't do anything, does it? Because to do anything, it needs to interoperate with native datastructures and functions. There you go...
- andrewaylett 9y agohttps://github.com/tsgates/rust.ko https://github.com/tsgates/rust.ko implements a simple module in Rust. When you can expose C bindings to your functions and don't need much runtime support, there aren't really many limitations to what you can do.
- jeffreyrogers 9y agoGood luck getting it in the mainline kernel though...
- masklinn 9y agoYou're not going to get a C++ kernel module in mainline either.
- jancsika 9y agoI'd be very curious to hear Linus' thoughts on Rust. Has anyone posted a flippant request on the kernel dev list to support kernel modules written in Rust? Be sure to mention: * how safe Rust is * how unsafe C is * reiterate that "this is the 21st century, people"
- steveklabnik 9y agoI hate to link to Quora, but I’m on mobile so I apologize in advance. The only time I’m aware of Linus commenting on Rust is https://www.quora.com/What-does-Linus-Torvalds-think-of-Rust https://www.quora.com/What-does-Linus-Torvalds-think-of-Rust I would hope that nobody trolls the LKML like that. Not even Rust people think that the kernel should adopt Rust.
- jancsika 9y agoThanks for that link-- that's about as good a compliment as I can imagine Linus giving another programming language. :)
- josteink 9y agoBy that reasoning C is the only language you can use to write kernel modules. Which is not a very interesting or productive reasoning when discussing the actual merits and capabilities of a programming language.
- jeffreyrogers 9y agoFor all practical purposes C is the only language that is used to write kernel modules on Linux. I like Rust a lot actually, but kernel modules aren't a good use case for it. Edit: the_grue actually has an interesting criticism of Rust, which is that a lot of existing systems problems-- problems that Rust would be well suited for--are already addressed with large C/C++ codebases. Since it's unlikely you're going to replace Linux, postgres, nginx, etc. it is interesting to ask what systems applications Rust can be used for now, without requiring people to rewrite their applications in Rust or allow Rust code to be mixed in with existing C/C++ code.
- johnny22 9y agoI definitely see why you couldn't replace linux or postgres with rust rewrites anytime soon, but nginx? Nginx seems totally probable.
- the_grue 9y ago> I like Rust a lot actually, but kernel modules aren't a good use case for it. If we're talking about kernel modules in general, I'd have to disagree. I think it's a perfect language for kernel, as long it's all written in Rust. I only wanted to point out the practical impossibility of integration with existing infrastructure, such as Linux kernel, which is written entirely in C.
- steveklabnik 9y agoIn general, Rust can work great with C projects. This is, after all, part of what it was originally created for: to replace bits of Firefox (which is C++, but that makes it harder, not easier). That said, the kernel has special requirements; I'd never advocate such a thing for Linux, specifically.