TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Greg K-H: "Writing new code in Rust is a win for all of us"

679 pointsby mustache_kimono3 months ago

34 comments

lazypenguin3 months ago
Linus response here seems relevant to this context: <a href="https:&#x2F;&#x2F;lore.kernel.org&#x2F;rust-for-linux&#x2F;CAHk-=wgLbz1Bm8QhmJ4dJGSmTuV5w_R0Gwvg5kHrYr4Ko9dUHQ@mail.gmail.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;lore.kernel.org&#x2F;rust-for-linux&#x2F;CAHk-=wgLbz1Bm8QhmJ4d...</a>
评论 #43123473 未加载
评论 #43123744 未加载
评论 #43123620 未加载
评论 #43125200 未加载
评论 #43127337 未加载
评论 #43123429 未加载
评论 #43125156 未加载
评论 #43124826 未加载
评论 #43123532 未加载
评论 #43125226 未加载
dfawcus3 months ago
The impression I get from simply reading these various discussions, is that some folks are not convinced that the pain from accepting Rust is worth the gain.<p>Possibly also that a significant portion of the suggested gain may be achievable via other means.<p>i.e. bounds checking and some simple (RAII-like) allocation&#x2F;freeing simplifications may be possible without rust, and that those are (from the various papers arguing for Rust &#x2F; memory safety elsewhere) the larger proportion of the safety bugs which Rust catches.<p>Possibly just making clang the required compiler, and adopting these extension may give an easier bang-for-buck: <a href="https:&#x2F;&#x2F;clang.llvm.org&#x2F;docs&#x2F;BoundsSafety.html" rel="nofollow">https:&#x2F;&#x2F;clang.llvm.org&#x2F;docs&#x2F;BoundsSafety.html</a><p>Over and above that, there seem to be various complaints about the readability and aesthetics of Rust code, and a desire not to be subjected to such.
评论 #43109746 未加载
评论 #43107843 未加载
评论 #43107544 未加载
评论 #43124682 未加载
评论 #43107970 未加载
评论 #43124052 未加载
评论 #43125198 未加载
评论 #43122664 未加载
评论 #43122368 未加载
typ3 months ago
In my honest opinion, it&#x27;s not a good idea to mix two programming languages into the same monolithic codebase <i>side by side</i>. It would be less problematic if used for different purposes or layers, like frontend and backend. But we know it still creates unpleasant friction when you have to work on both sides on your own. Otherwise, it creates technical AND communication friction if the C devs and Rust devs work separately. As someone who works with embedded systems at times, I can imagine the pain that you have to set up two toolchains (with vastly different build infra beasts like GNU Make and Cargo) and the prolonged build time of CI and edit-compile-run debugging cycles given the notorious slow compile time of the Rust&#x2F;LLVM compiler.
评论 #43123811 未加载
评论 #43123887 未加载
评论 #43124632 未加载
评论 #43123924 未加载
评论 #43124963 未加载
评论 #43123715 未加载
评论 #43123653 未加载
评论 #43126548 未加载
评论 #43124085 未加载
mmooss3 months ago
Regarding the Linux development process: How do Linux maintainers &#x2F; contributors have time to read these long threads of long posts? Just this one discussion looks like it would take hours to read and these are busy developers.<p>How does it work? Are there only a few threads that they read? Which ones?
评论 #43124547 未加载
评论 #43125946 未加载
评论 #43124761 未加载
评论 #43124533 未加载
评论 #43124606 未加载
评论 #43127674 未加载
评论 #43125471 未加载
mustache_kimono3 months ago
<p><pre><code> But for new code &#x2F; drivers, writing them in Rust where these types of bugs just can&#x27;t happen (or happen much much less) is a win for all of us, why wouldn&#x27;t we do this? -- greg k-h</code></pre>
评论 #43105365 未加载
voidr3 months ago
We should have seen this post before Hector Martin got so fed up that he decided to resign(to be fair, he probably had other issues as well that contributed).<p>I was very confused by the lack of an actual response from Linus, he only said that social media brigading is bad, but he didn&#x27;t give clarity on what would be the way forward on that DMA issue.<p>I have worked in a similar situation and it was the worst experience of my work life. Being stonewalled is incredibly painful and having weak ambiguous leadership enhances that pain.<p>If I were a R4L developer, I would stop contributing until Linus codifies the rules around Rust that all maintainers would have to adhere to because it&#x27;s incredibly frustrating to put a lot of effort into something and to be shut down with no technical justification.
评论 #43122057 未加载
评论 #43122049 未加载
AshamedCaptain3 months ago
I do not understand how this is supposed to work in practice. If there are &quot;Rust bindings&quot; then the kernel cannot have a freely evolving internal ABI, and the project is doomed to effectively split into the &quot;C&quot; core side and the &quot;Rust&quot; side which is more client oriented. Maybe it will be a net win for Linux for finally stabilizing the internal APIs, and even open the door to other languages and out-of-tree modules. On the other hand, if there are no &quot;Rust bindings&quot; then Rust brings very little to the table.
评论 #43122100 未加载
评论 #43122226 未加载
评论 #43122092 未加载
评论 #43127762 未加载
评论 #43122085 未加载
wewewedxfgdf3 months ago
Community and people are the main issue.<p>If the people who work on the kernel now don&#x27;t like that direction then that&#x27;s a big problem.<p>The Linux leadership don&#x27;t seem very focused on the people issues.<p>Where is the evidence that there is buy in from the actual people doing kernel development now?<p>Or is it just Linus and Greg as commanders saying &quot;thou shalt&quot;.
评论 #43122239 未加载
评论 #43122258 未加载
评论 #43122253 未加载
评论 #43125421 未加载
marhee3 months ago
&gt; The majority of bugs (quantity, not quality&#x2F;severity) we have are due to the stupid little corner cases in C .... Things like simple overwrites of memory (not that rust can catch all of these by far), error path cleanups, forgetting to check error values, and use-after-free mistakes.<p>What&#x27;s the reach here of linters&#x2F;address san&#x2F;valgrind?<p>Or a linter written specifically for the linux kernel? Require (error-path) tests? It feels excessive to plug another language if these are the main arguments? Are there any other arguments for using Rust?<p>And even without any extra tools to guard against common mistakes, how much effort is solving those bug fixes anyway? Is it an order of magnitude larger than the cognitive load of learning a (not so easy!) language <i>and</i> context-switching continuously between them?
评论 #43125612 未加载
WalterBright3 months ago
These days, the bugs I generate in my own code are rarely programming errors. They&#x27;re misunderstandings of the problem I am trying to solve, or misunderstandings of how to fit it into the rest of the (very complex) code.<p>For example, I cannot even recall the last time I had a double-free bug, though I used to do it often enough.<p>The emphasis for me is on a language that makes it easy to express algorithms.
评论 #43123999 未加载
评论 #43125568 未加载
MalseMattie3 months ago
This statement was sorely needed for this discussion to move forward. Hopefully the last section fills the needed parties with resolve
sim7c003 months ago
It&#x27;s really all opinions what is better or worse, but i do respect the sentiment that there is some boundary, and on one side of the boundary, Rust makes a lot of sense, and the other side, Rust does not work at all. (managing global mutable resources). It weirds me out a bit there is even such discussions going on in projects like this. It seems obvious and proven at this point and if not that then atleast it should be obvious already for a long time that if you program within some large codebase or ecosystem, you are not the only voice, and you need to learn to collaborate with people with different views as you and make it work.<p>I really don&#x27;t like rust, hence instead of wanting to contribute to projects which will inadvertently lead to more and more rust code being brought in, i start my own projects, when i can be the only voice of reason and have my joys of making things segfault :&gt;... Its quite simple. If like me you are stuobborn and unflexible, you are a lone wolf. accept it and move on to be happy :) rather than trying to piss against the wind of change.
评论 #43126860 未加载
infogulch3 months ago
The actual project is &quot;lets modernize the internal kernel api surface&quot;, and &quot;how tolerable is it to write against this api in rust&quot; is just the best metric at hand to measure the progress.<p>This is the correct frame for RFL proponents. You&#x27;re welcome.
评论 #43122575 未加载
lousken3 months ago
I wonder how Microsoft implements rust in their kernel.<p>As for this issue, it&#x27;s just a nature of any project, people will come and go regardless, so why not let those C developers leave and keep the rust folks instead? At some point you have to steer the ship and there will always be a group of people unhappy about the course
评论 #43125433 未加载
评论 #43124166 未加载
评论 #43123307 未加载
评论 #43110181 未加载
评论 #43119766 未加载
p_ing3 months ago
&gt; the C++ language committee issues seem to be pointing out that everyone better be abandoning that language as soon as possible<p>What is he referring to?
评论 #43122003 未加载
评论 #43109981 未加载
评论 #43122522 未加载
评论 #43122396 未加载
评论 #43123741 未加载
kelnos3 months ago
It&#x27;s really disappointing to me to see a lot of the negative reactions and comments here. I know it&#x27;s popular and in vogue now to hate on Rust, but:<p>Influential people who have worked on the ins and outs of the Linux kernel for years and decades believe that adopting Rust (or at least keeping the Rust experiment going) is worth the pain it will cause.<p>That&#x27;s really all that matters. I see people commenting here about how they think RAII isn&#x27;t suitable for kernel code, or how keeping C and Rust interfaces in sync will slow down important refactoring and changes, or how they think it&#x27;s unacceptable that some random tiny-usage architecture that Rust&#x2F;LLVM doesn&#x27;t support will be left behind, or... whatever.<p>So what! I&#x27;m not a Linux kernel developer or maintainer, and I suspect most (if not all) of the people griping here aren&#x27;t either. What does it matter to you if Linux adopts Rust? Your life will not be impacted in any way. All that matters is what the maintainers think. They think this is a worthwhile way to spend their time. The people putting in the work get to decide.
raverbashing3 months ago
&gt; The majority of bugs (quantity, not quality&#x2F;severity) we have are due to the stupid little corner cases in C that are totally gone in Rust. Things like simple overwrites of memory (not that rust can catch all of these by far), error path cleanups, forgetting to check error values, and use-after-free mistakes. That&#x27;s why I&#x27;m wanting to see Rust get into the kernel, these types of issues just go away, allowing developers and maintainers more time to focus on the REAL bugs that happen (i.e. logic issues, race conditions, etc.)<p>C committee, are you listening? Hello? Hello? Bueller?<p>(Unfortunately, if they are listening it is to make more changes on how compilers should take &quot;creative licenses&quot; in making developers shoot themselves in the foot)
评论 #43128571 未加载
okl3 months ago
Seems to me that everyone is focused on the technical merits, not weighing the effort of learning a new programming language&#x2F;toolchain&#x2F;ecosystem for the maintainers appropriately.<p>Mastering a new programming language to a degree that makes one a competent maintainer is nothing to sneeze at and some maintainers might be unwilling to based on personal interests&#x2F;motivation, which I&#x27;d consider legitimate position.<p>I think its important to acknowledge that not everyone may feel comfortable talking about their lack of competence&#x2F;disinterest.
评论 #43122058 未加载
评论 #43121838 未加载
评论 #43121827 未加载
chris_wot3 months ago
&quot;Rust also gives us the ability to define our in-kernel apis in ways that make them almost impossible to get wrong when using them. We have way too many difficult&#x2F;tricky apis that require way too much maintainer review just to &quot;ensure that you got this right&quot; that is a combination of both how our apis have evolved over the years&quot;<p>Funny, that&#x27;s not Theodore T&#x27;so&#x27;s position. The Rust guys tried to ask about interface semantics and he yelled at them:<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=WiPp9YEBV0Q&amp;t=1529s" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=WiPp9YEBV0Q&amp;t=1529s</a>
评论 #43125907 未加载
评论 #43121636 未加载
npalli3 months ago
Prediction 2030: Linus Retires and C++ accepted as the primary language for writing the kernel.<p>Inadvertently, Rust makes working with C++ acceptable.
评论 #43126679 未加载
daft_pink3 months ago
It’s hard. Most people agree it should have memory safety, but also I’m not looking to become a full scale maintainer either.
darksaints3 months ago
I&#x27;ve been using Linux since 2005, and I&#x27;ve loved it in almost every circumstance. But the drama over the last couple of years surrounding Rust in the kernel has really soured me on it, and I&#x27;m now very pessimistic about its future. But I think beyond the emotional outbursts of various personalities, I don&#x27;t think that the problem is which side is &quot;right&quot;. Both sides have extremely valid points. I don&#x27;t think the problem is actually solvable, because managing a 40M+ SLoC codebase is barely tenable in general, and super duper untenable for something that we rely on for security while running in ring 0.<p>My best hope is for replacement. I think we&#x27;ve finally hit the ceiling of where monolithic kernels can take us. The Linux kernel will continue to make extremely slow progress while it deals with internal politics fighting against an architecture that can only get bigger and less secure over time.<p>But what could be the replacement? There&#x27;s a handful of fairly mature microkernels out there, each with extremely immature userspaces. There doesn&#x27;t seem to be any concerted efforts behind any of them. I have a lot of hope for SeL4, but progress there seems to be slow mostly because the security model has poor ergonomics. I&#x27;d love to see some sort of breakout here.
评论 #43122011 未加载
评论 #43121900 未加载
评论 #43125966 未加载
评论 #43110704 未加载
评论 #43122613 未加载
评论 #43114828 未加载
chris_wot3 months ago
&quot;he C++ language committee issues seem to be pointing out that everyone better be abandoning that language as soon as possible if they wish to have any codebase that can be maintained for any length of time.&quot;<p>I&#x27;d love to know where he got this impression. The new C++ features go a long way to helping make the language easier, and safer, to use.
评论 #43125011 未加载
评论 #43127007 未加载
vs4vijay3 months ago
This might be a silly question, but why don&#x27;t we have something like PR Gate pipelines that ensures it passes before being picked up by a maintainer?
Surac3 months ago
perhaps someone can point me to a link where i can get information WHY it is so hard to call C from Rust or call into Rust code from C So i do not get the talk because i do not understand the issue.
评论 #43127475 未加载
评论 #43126933 未加载
nailer3 months ago
Pasting the entire thing so people on mobile can read (at least on iPhone readability doesn’t work here:<p>As someone who has seen almost EVERY kernel bugfix and security issue for the past 15+ years (well hopefully all of them end up in the stable trees, we do miss some at times when maintainers&#x2F;developers forget to mark them as bugfixes), and who sees EVERY kernel CVE issued, I think I can speak on this topic.<p>The majority of bugs (quantity, not quality&#x2F;severity) we have are due to the stupid little corner cases in C that are totally gone in Rust. Things like simple overwrites of memory (not that rust can catch all of these by far), error path cleanups, forgetting to check error values, and use-after-free mistakes. That&#x27;s why I&#x27;m wanting to see Rust get into the kernel, these types of issues just go away, allowing developers and maintainers more time to focus on the REAL bugs that happen (i.e. logic issues, race conditions, etc.)<p>I&#x27;m all for moving our C codebase toward making these types of problems impossible to hit, the work that Kees and Gustavo and others are doing here is wonderful and totally needed, we have 30 million lines of C code that isn&#x27;t going anywhere any year soon. That&#x27;s a worthy effort and is not going to stop and should not stop no matter what.<p>But for new code &#x2F; drivers, writing them in rust where these types of bugs just can&#x27;t happen (or happen much much less) is a win for all of us, why wouldn&#x27;t we do this? C++ isn&#x27;t going to give us any of that any decade soon, and the C++ language committee issues seem to be pointing out that everyone better be abandoning that language as soon as possible if they wish to have any codebase that can be maintained for any length of time.<p>Rust also gives us the ability to define our in-kernel apis in ways that make them almost impossible to get wrong when using them. We have way too many difficult&#x2F;tricky apis that require way too much maintainer review just to &quot;ensure that you got this right&quot; that is a combination of both how our apis have evolved over the years (how many different ways can you use a &#x27;struct cdev&#x27; in a safe way?) and how C doesn&#x27;t allow us to express apis in a way that makes them easier&#x2F;safer to use. Forcing us maintainers of these apis to rethink them is a GOOD thing, as it is causing us to clean them up for EVERYONE, C users included already, making Linux better overall.<p>And yes, the Rust bindings look like magic to me in places, someone with very little Rust experience, but I&#x27;m willing to learn and work with the developers who have stepped up to help out here. To not want to learn and change based on new evidence (see my point about reading every kernel bug we have.)<p>Rust isn&#x27;t a &quot;silver bullet&quot; that will solve all of our problems, but it sure will help in a huge number of places, so for new stuff going forward, why wouldn&#x27;t we want that?<p>Linux is a tool that everyone else uses to solve their problems, and here we have developers that are saying &quot;hey, our problem is that we want to write code for our hardware that just can&#x27;t have all of these types of bugs automatically&quot;.<p>Why would we ignore that?<p>Yes, I understand our overworked maintainer problem (being one of these people myself), but here we have people actually doing the work!<p>Yes, mixed language codebases are rough, and hard to maintain, but we are kernel developers dammit, we&#x27;ve been maintaining and strengthening Linux for longer than anyone ever thought was going to be possible. We&#x27;ve turned our development model into a well-oiled engineering marvel creating something that no one else has ever been able to accomplish. Adding another language really shouldn&#x27;t be a problem, we&#x27;ve handled much worse things in the past and we shouldn&#x27;t give up now on wanting to ensure that our project succeeds for the next 20+ years. We&#x27;ve got to keep pushing forward when confronted with new good ideas, and embrace the people offering to join us in actually doing the work to help make sure that we all succeed together.<p>thanks,<p>greg k-h
anonnon3 months ago
&gt; &gt; &gt; &gt; &gt; 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&#x27;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.<p>&gt; &gt; &gt;<p>&gt; &gt; &gt; That is great, but that does not give you memory safety and everyone<p>&gt; &gt; &gt; would still need to learn C++.<p>&gt; &gt;<p>&gt; &gt; The point is that C++ is a superset of C, and we would use a subset of C++<p>&gt; &gt; that is more &quot;C+&quot;-style. That is, most changes would occur in header files,<p>&gt; &gt; especially early on. Since the kernel uses a <i>lot</i> of inlines and macros,<p>&gt; &gt; the improvements would still affect most of the <i>existing</i> kernel code,<p>&gt; &gt; something you simply can&#x27;t do with Rust.<p>I have yet to see a compelling argument for allowing a completely new language with a completely different compiler and toolchain into the kernel while continuing to bar C++ entirely, when even just a restricted subset could bring safety- and maintainability-enhancing features <i>today</i>, such as RAII, smart pointers, overloadable functions, namespaces, and templates, and do so using the existing GCC toolchain, which supports even recent vintages of C++ (e.g., C++20) on Linux&#x27;s targeted platforms.<p>Greg&#x27;s response:<p>&gt; But for new code &#x2F; drivers, writing them in rust where these types of bugs just can&#x27;t happen (or happen much much less) is a win for all of us, why wouldn&#x27;t we do this? C++ isn&#x27;t going to give us any of that any decade soon, and the C++ language committee issues seem to be pointing out that everyone better be abandoning that language as soon as possible if they wish to have any codebase that can be maintained for any length of time.<p>side-steps this. Even if Rust is &quot;better,&quot; it&#x27;s much easier to address at least some of C&#x27;s shortcomings with C++, and it can be done without significantly rewriting existing code, sacrificing platform support, or the incorporation of a new toolchain.<p>For example, as pointed out (and as Greg ignored), the kernel is replete with macros--a poor substitute for genuine generic programming that offers no type safety and the ever-present possibility for unintended side effects due to repeated evaluation of the arguments, e.g.:<p>#define MAX(x, y) (((x) &gt; (y)) ? (x) : (y))<p>One need only be bitten by this kind of bug once to have it color your perception of C, permanently.
评论 #43110443 未加载
评论 #43109811 未加载
评论 #43125924 未加载
评论 #43140920 未加载
orf3 months ago
Christoph Hellwig seems fun to interact with. He drive-by posts the same, repeated points and seemingly refuses to engage with any replies.
评论 #43121242 未加载
评论 #43104576 未加载
stpedgwdgfhgdd3 months ago
No pain, no gain
stackedinserter3 months ago
What&#x27;s in Rust that creates drama in every project where it&#x27;s used?
评论 #43129273 未加载
oguz-ismail3 months ago
Aren&#x27;t these people tired of shaving that yak already? I wish they rather focused on making one (1) decent distro for desktop use.
评论 #43129248 未加载
dboreham3 months ago
I think it&#x27;s becoming apparent that any attempt to progressively re-write a large codebase into a new language is always going to fail. Needs to done ground up new.
评论 #43123618 未加载
评论 #43125196 未加载
评论 #43124905 未加载
cynicalsecurity3 months ago
Rust changes every few months. It&#x27;s simply not a mature language or people behind it have no idea what they are doing.
评论 #43122316 未加载
评论 #43123766 未加载
评论 #43122372 未加载
评论 #43124249 未加载
评论 #43124136 未加载
mimd3 months ago
Isn&#x27;t this a bait and switch, that all the c kernel devs were complaining about? That it wouldn&#x27;t be just drivers but also all new kernel code? The lack of candor over the goal of R4L and downplaying of other potential solutions should give any maintainer (including potential rust ones) pause.<p>Anyway, why just stop at rust? If we really care about safety, lets drop the act and go make everyone do formal methods. Frama-C is at least C, has a richer contract language, has heavy static analysis tools before having to go to proofs, is much more proven, and the list goes on. Or, why not add Spark to the codebase if we are okay with mixing langs in the codebase? Its very safe.
评论 #43109519 未加载
评论 #43114012 未加载
评论 #43122337 未加载