| |
I work on the kernel for a living, and I find this claim exceedingly dubious. We're currently talking about experimentally supporting modules written in Rust, which is an entirely different beast than replacing pieces of the kernel core. The barrier to entry for drivers is significantly lower, and driver quality can be much, much poorer than the quality of the core kernel.Many parts of the kernel have been fine tuned for decades, and many of the kernel developers that maintain Linux are also C experts (myself included) who aren't going to slow down development to migrate working code to Rust. It's great that we can experiment and see how Rust goes for driver authors, but they are still bus API consumers, not core kernel. | |
| |
As I understand it the crucial rationale for drivers is that drivers were anyway necessarily platform dependent which undoes one argument against Rust. Today Rust does not overlap Linux in terms of platform support. There are (small but very much alive) communities doing Linux on architectures that Rust has no support for and in some cases has no plans ever to support. So this makes drivers the only case where choosing Rust doesn't mean some people lose out, as a platform e.g. with no PCI bus doesn't get to run PCI drivers even if they were written in C. I expect that over the next say, five to ten years, two things will happen to greatly improve this, maybe to the point where you absolutely could rewrite core Linux code in Rust if you wanted to. Firstly, Rust will get more platform support. Linux doesn't really need Rust's "Tier 1" (Linus doesn't check every kernel release passes tests on all real Linux target hardware as I understand it) but clearly you want Rust to at least build and take patches for every Linux platform some day. Secondly, some older platforms will "rust out". If your community is nursing 30+ year old hardware and increasingly more maintenance work is shared between fewer shoulders at some point "Linux-next" is not a priority and your platform will stop being supported while effort moves to exciting new hardware. | |
| |
There's active work being done on the rust gcc backend and it's progressing nicely. That should help with some of the platform concerns you (rightly) raised. | |
| |
> Today Rust does not overlap Linux in terms of platform support. Nit, I believe actually the Rust and Linux platform sets would be considered "overlapping sets" in the mathematical sense :), since neither is a subset of the other. e.g. Rust platforms include things like the NetBSD Rump Kernel and Redox and I think one would be hard-pressed to claim that Linux supports those as platforms. https://doc.xuwenliang.com/docs/rust/1423 | |
| |
>I work on the kernel for a living I'm interested in kernel development and I like the idea of working on it for a living.Can you give more details about your job? What does it consist in? Is it mostly code-review? Or are you responsible for maintaining a part of the kernel.Who is the entity that pays you, and what are the criteria they'd use to pay a new contributor to work on kernel full-time?Finally, can you point me to beginner-friendly things to work on to get started? how do I know which part of the kernel I should study and contribute to? | |
| |
If you define quickly as "over the next 10-20 years, maybe", then yes | |
| |
In fairness, that is... if not quick, then not slow either in kernel development time:) | |
| |
Just as quickly as it replaced C/C++ in Firefox? | |
| |
Firefox is getting new "oxidized" component all the time, Rust is the recommended language for both refactoring and new development. Of course the lowest-hanging fruits are addressed first, but that's normal and advisable. | |
| |
Not after they let go everyone related to Rust, as far as I am aware. Hence the crazy idea of now using WebAssembly in Firefox modules instead. | |
| |
There's a big difference between "We don't employ the language's architects" (so far as I'm aware Mozilla also doesn't employ many WG21 members) and "We don't have any engineers who know this language". In 2022 you'd probably have to go out of your way to hire that many engineers and not get some people who know Rust. Not to mention how much less experience you need in Rust to not blow everybody's feet off by mistake. I reckon if you have 10 years C++ and six months Rust, any Rust you write is already more likely to deliver reasonable performance without setting everything on fire than your C++. Because of the constant exposure to outright malevolent stinking garbage (in the form of other people's HTML, CSS and Javascript) the browser needs to be exceptionally robust, and C++ just isn't very good for that. So Rust is often a better fit for what Mozilla do. | |
| |
Yet Chrome and Safari, the browsers that really matter in 2022, won't be moving away from C++. Chrome folks have been playing with Rust, but seem more keen in improving their C++ static analysis tooling instead. As for Mozilla, it is 10% of Rust code and lets see for how long Firefox still matters, given the existing 3% market, even EdgeChrome has surpassed it. | |
| |
> Chrome folks have been playing with Rust, but seem more keen in improving their C++ static analysis tooling instead. I would say that at this point that's good money after bad. Linus of course also put a bunch of effort into static analysis, that's what "sparse" is. The thing you run into immediately is that your programming language doesn't express the thing you wanted to analyse very well. So you have to annotate your software (Linux is sprinkled with sparse annotations), and now you've added an extra opportunity for mistakes, because the annotations are transparent to the compiler, so you can write code which analyses as correct but compiles to something incorrect. "Hooray". | |
|
| |
10% in a browser currently having 3% market share with a decreasing tendency towards 0%. Most of that code is surely related to what was replaced initially instead of new subsystems being ported. | |
| |
> 10% in a browser currently having 3% market share with a decreasing tendency towards 0%. Irrelevant to the question of how much Rust is in Firefox. > is surely Okay, it's clear you're not going to change your mind, no matter what. | |
| |
Please don't spout nonsense. They did not let go of "everyone related to Rust", large parts of Firefox are written in Rust and those parts obviously need to be maintained. New Rust code continues to be written, as others have pointed out. What Mozilla did do was lay off many of the people working on Rust itself as their full-time job, as opposed to people who use Rust to do their work at Mozilla. And the Servo team, unfortunately. | |
| |
Hence why I mentioned "as far as I am aware" instead of stating is a fact. The 10% as pointed out in a sibling comment, while admirable isn't large parts. | |
| |
It's more than it sounds like. As you can see from the breakdown someone posted [0], almost two-thirds of the Firefox codebase is HTML / JavaScript / Python (for tests) / assembly / Java (for Android), none of which is a candidate for being rewritten in Rust to begin with. If you just look at the portion written in native system languages, Rust is slightly more than 1/3 of that code already and still climbing. [0] https://4e6.github.io/firefox-lang-stats/ | |
| |
I'm new to programming, whats Firefox? | |
| |
Rust is great, but let's not get ahead of ourselves. :P | |
| |
I have no doubt we'll be seeing Rust kernel modules but quickly replacing C? I don't think that's realistic. | |
| |
I have a very strong doubt about it because Rust debugging still sucks. No debugger allows you to evaluate function calls AFAIK, which is a very strong restriction. | |
| |
That doesn't seem like it would matter in the Linux kernel, since they don't have a kernel debugger, for better or worse. | |
| |
Running GDB against the kernel running in QEMU? | |
| |
I have definitely evaluated function calls in rust-gdb. | |
| |
I see reports of it working for trivial top-level functions with basic parameter types, but what about everything else? Like member functions, trait implementations, etc. | |
| |
You’re absolutely right that it often fails on more complicated stuff. I’m just pointing out that it’s not _totally_ nonexistent. | |
| |
If by "replace" you mean "nobodies rewrite existing crap into Rust", then yes. | |
| |
That's a bit harsh of an approach. And I think at least Doom would disagree. | |
| |
he means in the context of a kernel developer. im sure there is some nerd who would rewrite stuff to prove to themselves and shutup their inner imposter syndrome. but mostly its quite accurate. | |
| |
> rewrite stuff to .. shutup their inner imposter syndrome you think that might do it? | |
| |
ffs dont do it. no its not enough. you will always feel that feeling because you are born into this world and it absolutely makes no f*cking sense. so you want to atleast feel competent in one thing. but you wont ever feel competent in life because this whole experience of existing is f*cking ridiculous. bla bla computer bla bla ping pong. you are an ape and we are spinning around. imposter in the world. not in knowing a "job" skill. haha you comment is so deep i wanna give you a hug and buy you a beer. | |
| |
Rust is evidently an impostor language. | |
| |
I agree that the parent claim ("Rust will quickly replace C in the Linux kernel") was utterly risible, but your comments just seem like the mirror image of theirs. What on earth is an 'impostor language'? Imposture of what or whom? I'm tired of having to deal with this culture war crap in our profession. These languages are tools. C, C++, and Rust all compile down to the same LLVM IR (or GCC if you stray from rustc). There are certainly semantic and grammatical peculiarities that affect how each of them do so[0], but by and large running a simple Rust program and a simple C program through Godbolt will do a lot to disabuse you of the idea that the two are irreconcilably different. To anyone else who wants to write performant Rust, my advice: (1) no_std, if only to focus the mind, (2) .try_foo(), not .foo(), b/c allocation is fallible, (3) always set `opt-level` to at least 1 (1 is far further from 0 than 3 is from 1, ime), (4) use stack-allocated alternatives to heap-allocated types ('smallvec' or equiv vs Vec, 'smolstr' vs String, &c) even at the expense of overallocating buffer space, (5) exploit vectorisation where possible (e.g. SIMD), in general practising mechanical sympathy, and (5) parallelism is not a panacea, whereas cache locality usually is. Measure everything, but also: memorise every instruction and how many cycles it takes, and think in those terms - in terms of your assembled, perhaps-handmodified code - rather than unscientific laptop benchmarks. (Jeff Dean's famous 'numbers every programmer should know' are a good start but are just the very basics, and obv his exact values are long obsolete, in some areas [disk] more than others [CPU].) [0] These are discussed extremely soberly and intelligently here, for you or anyone else who may be interested: https://kornel.ski/rust-c-speed | |
| |
It's an impostor because it doesn't belong in the kernel. Or anywhere else for that matter - look at Firefox sources. It just causes fragmentation and its security is yet to be proven. From my POV, it's just written by people too lazy for C and too ignorant for C++. | |
| |
bah to me people who write C and C++ whine too much should be force sterilised so that us real humans can have peace and quiet and write our machine code and bring our albatrosses to work. like you people who use querty? they should just stop smoking pot and learn to use morse code and why arent phone numbers in hex? its like the world is full of ignorant lazy people. i mean its just my POV. i dont mean i want to promote force sterilisation on C++ and C programmers for being too underdeveloped to function and have a home. i just am talking from my POV you know? anyway good comment. | |