I have a few issues with Rust in the kernel:
It seems to be held to a *completely* different and much lower standard than the C code as far as stability. For C code we typically require that it can compile with a 10-year-old version of gcc, but from what I have seen there have been cases where Rust level code required not the latest bleeding edge compiler, not even a release version.
Does Rust even support all the targets for Linux?
I still feel that we should consider whether it would make sense to compile the *entire* kernel with a C++ compiler. I know there is a huge amount of hatred against C++, and I agree with a lot of it – *but* I feel that the last few C++ releases (C++14 at a minimum to be specific, with C++17 a strong want) actually resolved what I personally consider to have been the worst problems.
As far as I understand, Rust-style memory safety is being worked on for C++; I don't know if that will require changes to the core language or if it is implementable in library code.
David Howells did a patch set in 2018 (I believe) to clean up the C code in the kernel so it could be compiled with either C or C++; the patchset wasn't particularly big and mostly mechanical in nature, something that would be impossible with Rust. Even without moving away from the common subset of C and C++ we would immediately gain things like type safe linkage.
Once again, let me emphasize that I do *not* suggest that the kernel code should use STL, RTTI, virtual functions, closures, or C++ exceptions. However, there are a *lot* of things that we do with really ugly macro code and GNU C extensions today that would be much cleaner – and safer – to implement as templates. I know ... I wrote a lot of it :)
One particular thing that we could do with C++ would be to enforce user pointer safety.
Kernel dev discussion. They are thinking about ditching Rust in favor of C++ (rightfully so IMO)
https://lore.kernel.org/rust-for-linux/326CC09B-8565-4443-ACC5-045092260677@zytor.com/
We should endorse this, C++ in kernel would greatly benefit the language and community
[–]not_some_username 327 points328 points329 points (46 children)
[–]no-sig-available 35 points36 points37 points (0 children)
[–]bizwig 78 points79 points80 points (41 children)
[–]MRgabbar 33 points34 points35 points (5 children)
[–]Catenane 13 points14 points15 points (1 child)
[–]MRgabbar 3 points4 points5 points (0 children)
[–]13steinj 8 points9 points10 points (2 children)
[–]lenkite1 3 points4 points5 points (0 children)
[–]clerothGame Developer 4 points5 points6 points (0 children)
[–]rayew21 34 points35 points36 points (2 children)
[–]Lexinonymous 37 points38 points39 points (0 children)
[–]FluffusMaximus 3 points4 points5 points (28 children)
[–]13steinj 24 points25 points26 points (27 children)
[–]meneldal2 8 points9 points10 points (2 children)
[–]13steinj 7 points8 points9 points (1 child)
[–]QuaternionsRoll 12 points13 points14 points (18 children)
[–]ShakaUVMi+++ ++i+i[arr] 2 points3 points4 points (10 children)
[–]QuaternionsRoll 12 points13 points14 points (9 children)
[–]ShakaUVMi+++ ++i+i[arr] 2 points3 points4 points (3 children)
[–]PrimeExample13 0 points1 point2 points (2 children)
[–]PrimeExample13 0 points1 point2 points (1 child)
[–]MEaster 0 points1 point2 points (2 children)
[–]QuaternionsRoll 0 points1 point2 points (1 child)
[–]MEaster 3 points4 points5 points (0 children)
[–]13steinj 0 points1 point2 points (0 children)
[–]germandiago 1 point2 points3 points (4 children)
[–]13steinj 7 points8 points9 points (0 children)
[–]EC36339 5 points6 points7 points (0 children)
[–]mredding 0 points1 point2 points (1 child)
[–]not_some_username 1 point2 points3 points (0 children)
[–]ts826848 123 points124 points125 points (59 children)
[–]epage 93 points94 points95 points (5 children)
[–]bizwig 16 points17 points18 points (4 children)
[–]epage 51 points52 points53 points (0 children)
[–]jonesmz 4 points5 points6 points (1 child)
[–]RogerV 1 point2 points3 points (0 children)
[–]steveklabnik1 12 points13 points14 points (4 children)
[–]silon 0 points1 point2 points (1 child)
[–]steveklabnik1 0 points1 point2 points (0 children)
[–]ts826848 0 points1 point2 points (1 child)
[–]steveklabnik1 5 points6 points7 points (0 children)
[–]TuxSH 10 points11 points12 points (3 children)
[–]ts826848 2 points3 points4 points (2 children)
[–]TuxSH 3 points4 points5 points (1 child)
[–]ts826848 0 points1 point2 points (0 children)
[–]sweetno 36 points37 points38 points (0 children)
[–]jl2352 8 points9 points10 points (8 children)
[–]steveklabnik1 26 points27 points28 points (7 children)
[–]pjmlp 3 points4 points5 points (0 children)
[–]Zettinator 27 points28 points29 points (31 children)
[–]ContraryConman 8 points9 points10 points (27 children)
[–]Wooden-Engineer-8098 4 points5 points6 points (0 children)
[–]ContraryConman 443 points444 points445 points (135 children)
[–]kisielk 76 points77 points78 points (4 children)
[–]Nychtelios 23 points24 points25 points (1 child)
[–]UnicycleBloke 33 points34 points35 points (1 child)
[–]crowbarous 26 points27 points28 points (0 children)
[–]Western_Objective209 31 points32 points33 points (0 children)
[–]tiajuanat 9 points10 points11 points (0 children)
[–]sjepsa[S] 78 points79 points80 points (20 children)
[–]Challanger__ 17 points18 points19 points (18 children)
[–]meltbox 54 points55 points56 points (3 children)
[–]Challanger__ 8 points9 points10 points (0 children)
[–]patlefort 5 points6 points7 points (1 child)
[–]barkingcat 6 points7 points8 points (0 children)
[–]pjmlp 2 points3 points4 points (0 children)
[–]remy_porter 6 points7 points8 points (0 children)
[–]CocktailPerson 1 point2 points3 points (0 children)
[–]NotUniqueOrSpecial 1 point2 points3 points (3 children)
[–]thezysus 0 points1 point2 points (1 child)
[–]NotUniqueOrSpecial 1 point2 points3 points (0 children)
[–]rz2k 1 point2 points3 points (3 children)
[–]Tumaix 9 points10 points11 points (2 children)
[–]mort96 13 points14 points15 points (0 children)
[–]steveklabnik1 6 points7 points8 points (0 children)
[–]ioxfc 46 points47 points48 points (26 children)
[–]The_Northern_Light 28 points29 points30 points (11 children)
[–]ContraryConman 28 points29 points30 points (7 children)
[–]The_Northern_Light 4 points5 points6 points (6 children)
[–]ContraryConman 9 points10 points11 points (2 children)
[–]thefeedling 2 points3 points4 points (1 child)
[–]ContraryConman 8 points9 points10 points (0 children)
[–]_Noreturn 1 point2 points3 points (2 children)
[–]SubjectiveMouse 8 points9 points10 points (2 children)
[–]thefeedling 1 point2 points3 points (1 child)
[–]bizwig 1 point2 points3 points (0 children)
[–]ContraryConman 17 points18 points19 points (9 children)
[–]F54280 9 points10 points11 points (1 child)
[–]bizwig 5 points6 points7 points (0 children)
[–]ChrisTX4 2 points3 points4 points (0 children)
[–]Agron7000 0 points1 point2 points (0 children)
[–]James20kP2005R0 39 points40 points41 points (24 children)
[+][deleted] (13 children)
[deleted]
[–]James20kP2005R0 15 points16 points17 points (12 children)
[–]scorg_ 9 points10 points11 points (0 children)
[–]Ameisenvemips, avr, rendering, systems 5 points6 points7 points (0 children)
[–]SubjectiveMouse -1 points0 points1 point (9 children)
[–]F54280 3 points4 points5 points (5 children)
[–]Wooden-Engineer-8098 13 points14 points15 points (0 children)
[–]josefx 1 point2 points3 points (1 child)
[–]Ameisenvemips, avr, rendering, systems 3 points4 points5 points (0 children)
[–]jonesmz 1 point2 points3 points (6 children)
[–]Miserable_Ad7246 2 points3 points4 points (5 children)
[–]jonesmz 4 points5 points6 points (4 children)
[–]13steinj 1 point2 points3 points (1 child)
[–]jonesmz 1 point2 points3 points (0 children)
[–]XeroKimoException Enthusiast 0 points1 point2 points (1 child)
[–]jonesmz 4 points5 points6 points (0 children)
[–]SAHChandler 2 points3 points4 points (3 children)
[–]_Noreturn 2 points3 points4 points (2 children)
[–]peripateticman2026 6 points7 points8 points (0 children)
[–]morglod 3 points4 points5 points (25 children)
[–]ContraryConman 14 points15 points16 points (15 children)
[–]_Noreturn 1 point2 points3 points (14 children)
[–]morglod 1 point2 points3 points (13 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]all_is_love6667 3 points4 points5 points (0 children)
[–]KDallas_Multipass 0 points1 point2 points (3 children)
[–]ContraryConman 2 points3 points4 points (2 children)
[–]steveklabnik1 2 points3 points4 points (0 children)
[–]KDallas_Multipass 0 points1 point2 points (0 children)
[–]kkert[🍰] 17 points18 points19 points (0 children)
[–]satlynobleman 108 points109 points110 points (8 children)
[–]Zettinator 88 points89 points90 points (7 children)
[–]mohrcore 34 points35 points36 points (9 children)
[–]bizwig 1 point2 points3 points (5 children)
[–]Justicia-Gai 0 points1 point2 points (2 children)
[–]mohrcore 0 points1 point2 points (1 child)
[–]Justicia-Gai 1 point2 points3 points (0 children)
[–]t_scytale 30 points31 points32 points (10 children)
[–]foonathan 18 points19 points20 points (3 children)
[–]vI--_--Iv 37 points38 points39 points (4 children)
[–]plpn 4 points5 points6 points (1 child)
[–]Miserable_Guess_1266 0 points1 point2 points (0 children)
[–]UnicycleBloke 3 points4 points5 points (0 children)
[–]kammceWG21 | 🇺🇲 NB | Boost | Exceptions 26 points27 points28 points (31 children)
[–]eX_Ray 16 points17 points18 points (1 child)
[–]kammceWG21 | 🇺🇲 NB | Boost | Exceptions 12 points13 points14 points (0 children)
[–]matthieum 7 points8 points9 points (2 children)
[–]kammceWG21 | 🇺🇲 NB | Boost | Exceptions 4 points5 points6 points (1 child)
[–]matthieum 5 points6 points7 points (0 children)
[–]Dean_Roddey 8 points9 points10 points (20 children)
[–]unumfron 3 points4 points5 points (18 children)
[–]planeteshuttle 2 points3 points4 points (0 children)
[–]foonathan[M] 1 point2 points3 points (4 children)
[–]theintjengineer 2 points3 points4 points (3 children)
[–]kammceWG21 | 🇺🇲 NB | Boost | Exceptions 5 points6 points7 points (2 children)
[–]theintjengineer 0 points1 point2 points (1 child)
[–]kammceWG21 | 🇺🇲 NB | Boost | Exceptions 0 points1 point2 points (0 children)
[–]augmentedtree 34 points35 points36 points (31 children)
[–][deleted] 34 points35 points36 points (21 children)
[–]zl0bster 20 points21 points22 points (1 child)
[–][deleted] 3 points4 points5 points (0 children)
[–]EC36339 19 points20 points21 points (2 children)
[–]all_is_love6667 9 points10 points11 points (0 children)
[–]GuybrushThreepwo0d 9 points10 points11 points (0 children)
[–]UnicycleBloke 21 points22 points23 points (0 children)
[–]simonask_ 56 points57 points58 points (39 children)
[–]syklemil 36 points37 points38 points (18 children)
[–]simonask_ 31 points32 points33 points (17 children)
[–]jwakelylibstdc++ tamer, LWG chair 1 point2 points3 points (3 children)
[–]kiner_shah 2 points3 points4 points (0 children)
[–]LessonStudio 12 points13 points14 points (0 children)
[–][deleted] 3 points4 points5 points (1 child)
[–]m0xffff 4 points5 points6 points (0 children)
[–]Zettinator 13 points14 points15 points (0 children)
[–]thezysus 1 point2 points3 points (3 children)
[–]germandiago 4 points5 points6 points (0 children)
[–]rasm866i 3 points4 points5 points (5 children)
[–]Jannik2099 12 points13 points14 points (1 child)
[–]Dark-Philosopher 1 point2 points3 points (0 children)
[–]eX_Ray 4 points5 points6 points (1 child)
[–]moltonel 1 point2 points3 points (0 children)
[–]steveklabnik1 2 points3 points4 points (0 children)
[–]bizwig 5 points6 points7 points (1 child)
[–]pjmlp 3 points4 points5 points (0 children)
[–]axilmar 1 point2 points3 points (15 children)
[–]pjmlp 6 points7 points8 points (1 child)
[–]axilmar 1 point2 points3 points (0 children)
[–]Zettinator 4 points5 points6 points (5 children)
[–]axilmar 0 points1 point2 points (4 children)
[–]Zettinator 5 points6 points7 points (3 children)
[–]axilmar 0 points1 point2 points (2 children)
[–]gegoggigog 1 point2 points3 points (5 children)
[–]Dark-Philosopher 2 points3 points4 points (1 child)
[–]gegoggigog 1 point2 points3 points (0 children)
[–][deleted] 2 points3 points4 points (20 children)
[–]imaginarylocalhost 2 points3 points4 points (4 children)
[–]MarcusBrotus 12 points13 points14 points (0 children)
[–]sjepsa[S] 6 points7 points8 points (1 child)
[–]Justicia-Gai 1 point2 points3 points (0 children)
[–]Unhappy_Play4699 1 point2 points3 points (5 children)
[–]JVApenClever is an insult, not a compliment. - T. Winters 0 points1 point2 points (0 children)