Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Linux

Mixing Rust and C in Linux Likened To Cancer By Kernel Maintainer (theregister.com) 90

A heated dispute has erupted in the Linux kernel community over the integration of Rust code, with kernel maintainer Christoph Hellwig likening multiple programming languages to "cancer" for the project's maintainability. The conflict centers on a proposed patch enabling Rust-written device drivers to access the kernel's DMA API, which Hellwig strongly opposed. While the dispute isn't about Rust itself, Hellwig argues that maintaining cross-language codebases severely compromises Linux's integrated nature. From a report: "Don't force me to deal with your shiny language of the day," he [Hellwig] wrote. "Maintaining multi-language projects is a pain I have no interest in dealing with. If you want to use something that's not C, be that assembly or Rust, you write to C interfaces and deal with the impedance mismatch yourself as far as I'm concerned." This resistance follows the September departure of Microsoft engineer Wedson Almeida Filho from the Rust for Linux project, citing "nontechnical nonsense."

Mixing Rust and C in Linux Likened To Cancer By Kernel Maintainer

Comments Filter:
  • by Anonymous Coward
    -- Steve Ballmer
    • When he made that comment, cancer was the big baddie - now it's Nazi.
      • by narcc ( 412956 )

        We thought we stamped those fuckers out back in the 40's. Who knew those roaches would come crawling back out of the sewer?

        Hopefully, enough us us remember how real American's deal with Nazi scum.

        • Turns out that you can't simply wipe out fascists once and be done with it. They're like terminates or roaches, and you have to keep wiping them out to keep the infestation at bay.

          The Greatest Generation did the hard work. But Boomers and Gen X didn't keep up with the necessary maintenance. So kids, if you want to blame someone, blame your lazy, feckless parents.

          • I'd still blame the boomers. They're the reason why most of GenX has lead poison damaged brains.
            Might explain why we have so many crazies right now in their 40s and 50s.

            POTUS might skip my generation.

        • by caseih ( 160668 )

          Fascism is a product of human nature. It takes continual work and deliberately choosing a different path to keep it at bay. Trump has certainly encouraged and fostered this natural human tendency towards fascism and has really empowered a bunch of people who've embraced their fascist nature, such as Musk. Trump himself can cause lots of destruction, but that's nothing compared to what will follow when he's gone.

          • Wokeism is a product of human nature. It takes continual work and deliberately choosing a different path to keep it at bay. Univeristies have certainly encouraged wokeism and have really empowered a bunch of people who've embraced their wokeist nature, such as Karmaller. The Democrats themselves can cause lots of destruction, but that's nothing compared to what will follow when Trump is gone.
  • Team Hellwig (Score:5, Insightful)

    by JoshZK ( 9527547 ) on Thursday February 06, 2025 @02:27PM (#65147637)
    The dude is speaking from the soul.
  • what's the problem? (Score:4, Interesting)

    by ZipNada ( 10152669 ) on Thursday February 06, 2025 @02:29PM (#65147647)

    Objecting to "enabling Rust-written device drivers to access the kernel's DMA API"?

    It sure seems innocuous to me. There's an API, Rust could have access to it, why is that a problem? This particular Hellwig guy, who apparently doesn't know Rust, would obviously not be asked to maintain any of the Rust code so why should he care?

    • I must say, I'm kinda confused about what makes this a problem too.

      I get that having multiple languages and some overhead. Yeah, granted.

      But I thought part of the point of having an API is decoupling from a particular language.

      Is this just a "get off my lawn" complaint from someone who doesn't want the world to pass him by (as it will all of us someday)?

      • by 93 Escort Wagon ( 326346 ) on Thursday February 06, 2025 @03:10PM (#65147765)

        I must say, I'm kinda confused about what makes this a problem too.

        I get that having multiple languages and some overhead. Yeah, granted.

        But I thought part of the point of having an API is decoupling from a particular language.

        Is this just a "get off my lawn" complaint from someone who doesn't want the world to pass him by (as it will all of us someday)?

        Originally I agreed with you, but after re-reading TFS... it seems like the API is already there, but the rust devs want the API patched to better work with their rust code. That's what the guy is complaining about - it's a rust-specific patch to the API, which is the opposite of "decoupling from a particular language".

        So why not just reject the patch and tell the rust devs "go ahead and use rust, but the onus is on you to make your code work with the existing API"?

        • by ceoyoyo ( 59147 ) on Thursday February 06, 2025 @03:32PM (#65147823)

          I read it as the library API uses C conventions and the Rust types want an additional library with an API that uses Rust conventions. I assume Rust doesn't use C conventions like everything else because of some code safety thing.

          I've seen decent sized projects that used multiple languages and they were a maintainability nightmare. Multiple versions of the same thing in or for different languages sounds worse.

          • by mysidia ( 191772 )

            I read it as the library API uses C conventions and the Rust types want an additional library with an API that uses Rust conventions. I assume Rust doesn't use C conventions like everything else because of some code safety thing.

            If that is the case, then there is a solution: Create a shim library maintained by the rust developers that takes Other semantics and translates the library call to the C API. The Shim library could be written in Javascript for all I care; as long as one of the options offer

        • Hmm. That casts a different light. Thanks.

        • >> tell the rust devs "go ahead and use rust, but the onus is on you to make your code work with the existing API"?

          As I read it, that's what they want to do but this Hellwig guy is opposed even to that.

          "the C side of the kernel stays the same, and Rust drivers use abstractions to that C code, and that these abstractions are maintained by a team centrally in rust/kernel, all of which is arguably better than drivers having their own individual C bindings."

          • If that's indeed the situation, it seems entirely reasonable. But I have trouble jibbing that with the mention of patching the API.

          • That's what I'm seeing as well. He wants each individual driver to have its own C bindings. That doesn't make any sense and feels like it would make things even more painful for maintainers.

            It seems like he's doing exactly what Linus Torvalds was saying some developers do. In other words, it's going like this:

            * Patch to rust/kernel submitted

            Hellwig: kernel/dma is mine. Keep out

            Ojeda: We didn't even touch it, we only created a common rust binding in our own chode to make runtime DMA access more ergonomic. Wh

    • by DarkOx ( 621550 ) on Thursday February 06, 2025 @03:03PM (#65147751) Journal

      Because he is being asked to create data structures that don't make sense if you are working in C. IMHO Linus has made a huge mistake letting Rust into the kernel. I have never seen a multi-language project that did not suck. With small exceptions where something jython is included as scripting interface or something in a larger Java project.

      One language is always the master, and the others are always second class citizens. You end up with a bunch of stupid glue and marshaling, coupled with dumb performance killing polling solutions or complex trampoline dispatch stuff because Lang-A can't call into Lang-B so you can't give Lang-A pointer to your Lang-B function. Finally for all your trouble you lose the really useful language features. Hey great we can crank out these modules in JRuby and leave the rest of of our project Java, yeah except the Ruby code ends up looking just like Java code because all the Java objects can't take blocks...

        I have all the same experience with mixing VB and with C, and C with .Net and so fourth it really does not work.

      The the johny-come-lately language people show up and say, our stuff works on the 32-bit build but breaks on the 64-bit build. You say well because you are doing pointer arithmetic and your environment does not understand the sizes of the primitives are different when the target is. Then it turns into can you embed the size of the structures somewhere ....

      Its always a mess. Linux is C project, it should stay a C project. Do full port of the Kernel and primary user land to Rust if you want a Rust based system - it would probably be fantastic and more secure; but trying to cram Rust into C-Linux is just going to be a lot of suck.

      • Dont talk sense around here, the Rust fanboys will mod you to hell because Rust is the One True Language that will sweep all before it and must be shoehorned in to a multi million line C codebase Just Because.

      • You mean he's being asked to fully document the API?

        There is a clear separation between C and Rust in the kernel. They're in different parts of the source tree. The dependency is also one-way.
        It's helpful to Rust development if the C API is complete and every part of it is defined in code, not conventions.
        This guy doesn't seem to want to maintain more robust C code.

      • by gweihir ( 88907 ) on Thursday February 06, 2025 @03:47PM (#65147865)

        Yep, pretty much. And add that the Linux kernel is by now probably the largest software project that has ever succeeded and you realize that there is a delicate balance and upsetting that balance is a really stupid thing to do. Describing it as a "cancer" may be a gross understatement.

      • >> Because he is being asked to create data structures that don't make sense

        I'm not seeing that anywhere. "a patch was submitted that would allow Rust drivers to use the DMA API's dma_alloc_coherent() C function to allocate and map large memory regions for direct memory access by hardware.", seems entirely reasonable. And "the patch added code to the rust/kernel portion of the Linux source tree, not kernel/dma". Hellwig would never have to look at any of that if he doesn't want to, it is being maintai

        • by bsolar ( 1176767 ) on Thursday February 06, 2025 @04:37PM (#65148025)

          I'm not seeing that anywhere. "a patch was submitted that would allow Rust drivers to use the DMA API's dma_alloc_coherent() C function to allocate and map large memory regions for direct memory access by hardware.", seems entirely reasonable.

          I don't see that either: the main argument is not wanting to have an additonal middle-layer abstraction. The rust guys seem to want a centralized API that can be reused by multiple differente device-driver, whereas the dma-api maintaner wants no middle-layer abstraction and want the device-drivers to deal with the abstraction themselves.

          There is an acknowledgement that the middle-layer may introduce maintenance burden though. Reference here [kernel.org].

          And "the patch added code to the rust/kernel portion of the Linux source tree, not kernel/dma". Hellwig would never have to look at any of that if he doesn't want to, it is being maintained by the Rust folks.

          That has also been offered, but in the thread there are some counter-arguments, e.g.: this example [kernel.org]:

          You'd have to reconcile that with the recent event where Linus defered the MM pull request and some C patches were dropped because of rust kbuild bugs:

          All PRs to Linus must not break the rust build and the responsibilty for that falls to all the maintainers. If the Rust team is not quick enough to resolve any issues during the development window then patches must be dropped before sending PRs, or Linus will refuse the PR.

          Also for reference, Linus' only reply so far is to criticize the attempt to social media brigading [kernel.org]:

          • That example kind of reads like 'people unwittingly breaking the Linux driver API are now made aware of the fact, and need to make sure it gets fixed before the PR can be accepted.'

            Isn't it good practise, when building a public API to have multiple independent clients, to ensure your API is complete, documented and doesn't require special knowledge or tools to use?

      • He is not being asked to do anything.

        Some developer is intending to add a .rs file with some bindings and to officially maintain it.

        Hellwig doesn't want any .rs file in the kernel/dma. And, honestly, his only "technical" argument has been: "...so that it reminds greppable and maintainable"

        I won't pretend to know if rust should be in the kernel code or not but I am fairly certain that arguments against rust code cannot be "to keep the code greppable".

        There is obviously tension on the topic.

        • by mysidia ( 191772 )

          He is not being asked to do anything.
          Some developer is intending to add a .rs file with some bindings and to officially maintain it.

          He is having an implicit constraint added to his work as a developer that he can't make changes that break the Rust build which will now depend on his C code without seeing to it himself that the Rust code is updated.

        • It's not even that, no one wants to put rust code in kernel/dma

      • One language is always the master, and the others are always second class citizens. You end up with a bunch of stupid glue and marshaling, coupled with dumb performance killing polling solutions or complex trampoline dispatch stuff because Lang-A can't call into Lang-B so you can't give Lang-A pointer to your Lang-B function.

        Thing is though that Rust has basically the underlying model of the machine as C and of course C++. They all represents fundamental types, aggregates and pointers.

        C is very bare bones.

    • by ljw1004 ( 764174 ) on Thursday February 06, 2025 @03:21PM (#65147797)

      Objecting to "enabling Rust-written device drivers to access the kernel's DMA API"? It sure seems innocuous to me. There's an API, Rust could have access to it, why is that a problem? This particular Hellwig guy, who apparently doesn't know Rust, would obviously not be asked to maintain any of the Rust code so why should he care?

      The problem I heard last time around is that if someone wants to update the API (say) then they also have to update all callsites. Previously they could achieve this solely in C. Now they have to learn Rust as well to figure out how to update the callsites.

  • Why? (Score:5, Interesting)

    by SumDog ( 466607 ) on Thursday February 06, 2025 @02:32PM (#65147659) Homepage Journal
    Why is there such a push to get Rust into the kernel? Memory safety? It's only memory safe up to the borders of the module, at which point you will need to make an unsafe call. Okay, so we have more safety within the Rust driver itself. I mean, maybe that's a good enough reason?

    But having a single project in multiple languages is a maintenance hassle. Rust is not an easy language to get into. It's gotten better, but in the early days every code example was either for an older version of Rust or a newer version of Rust (rustup wasn't around, and since when are we okay have a virtual env tool for a bloody system language?! You don't need that for most Go projects!)

    If Rust is so great, why does it need special hooks in the Linux source code? Why doesn't it have functionality within the language to connect to existing C kernel header includes to build modules? It's literally a new language that's constantly broken. Why not just implement that? Why not just fix your stupid fucking language so you don't need the kernel team to do anything?

    Rust is such a meme language. I'm sure it's an okay language, but I don't understand why it needs to be forced into everything. It's exactly like the type of people who use it, forcing their ideas and ideology onto a population that does not care.
    • Re:Why? (Score:4, Interesting)

      by HiThere ( 15173 ) <{ten.knilhtrae} {ta} {nsxihselrahc}> on Thursday February 06, 2025 @02:41PM (#65147677)

      The best answer is write a rust to c compiler (and a companion decompiler). That way you can write your code in rust, and I won't have to deal with it.

      The problem with that answer is that language-to-language compilers tend to produce unreadable code. But if you maintain the rust code, and the compiler is good, that step won't be needed.

      Consider, e.g., the Vala to C compiler. The C it generates is horrible, but valid. And people writing in Vala never need to look at the generated C. (I'm not actually sure how good that compiler is, but it's a convenient example. And it's used for interfacing with C code.)

      • Re:Why? (Score:4, Insightful)

        by TheMiddleRoad ( 1153113 ) on Thursday February 06, 2025 @02:56PM (#65147717)

        Seems to be that not knowing exactly what the unreadable C code is doing might be problematic.

        • by HiThere ( 15173 )

          If you really want to, you can. It's just not easy. Compilers write code that's designed to be accurate and (hopefully) efficient. But I've never seen one that writes the kind of code a person would. (Well, I've only seen about 5 examples, so that's not a proof, just a strong indication.)

      • by Anonymous Coward

        Or ideally, stop being a rust fag and learn C.

      • by gweihir ( 88907 )

        Seriously, no. Kernel code needs to be well readable. Another reason to only have one language in there.

    • by Anonymous Coward

      I was going to write a longer reply, but all those questions have been asked and answered so many times already that it would be pointless. This post is just pure flamebait.

      Now, let me get off your lawn.

    • by ljw1004 ( 764174 )

      Why is there such a push to get Rust into the kernel? Memory safety? It's only memory safe up to the borders of the module, at which point you will need to make an unsafe call.

      https://ferd.ca/complexity-has... [ferd.ca]

      Complexity has to live somewhere. If your a skilled programmer then you find ways to keep the complexity in small well-defined parts of your codebase that don't leak out, are carefully documented, and are particularly well covered by tests. If you're not, then complexity spreads its way into all areas of your codebase.

      Memory unsafety is very similar. And Rust has proved particularly good at keeping people honest about those "small well-defined parts" with respect to memory

    • Rust can call C code.
      It's just better if the C API being used is written correctly and isn't full of untyped bullshit that is only documented in comments.
      Proper structures and argument declarations help out everyone.

    • Re:Why? (Score:5, Insightful)

      by gweihir ( 88907 ) on Thursday February 06, 2025 @03:52PM (#65147879)

      The Rust fanatics do not understand the limits of their language and that language used is just one aspect of a software project and its security. Essentially, this is aggressive incompetence.

      The other risk, besides that a multi-language project of this size is an excessively bad idea and can only lead to project failure, is that Rust is really hard to learn. Getting it into major components will doom the Linux kernel, because there are not enough people that can keep it alive after that.

      That said, I still think Linus only let these assholes and their fetish into the kernel to give them enough rope to hang themselves because they would not shut up and accept reality.

  • because they fool you into thinking you have a handle on timing or memory footprint when in fact there's stuff going on under the hood you're not aware off.

    Even "hard" languages like C can fool you into doing something stupid. For example:

    for(int i=0; i
    can bite you in the ass in terms of execution speed, since even if the limit() function is straightforward and short and constant throughout the loop execution, the compiler has no way of knowing that and you buy yourself a function call overhead on each loop

  • If you don't understand why this is such a big issue go look at the chromium code base.

    It's primarily a C++ code base and the rust cult members are also trying to convert it to rust and enable rust stuff but the rust stuff they added is so bad that it doesn't even use stable, and so this creates a lot of build problems and requires that one person that really isn't friendly to the Internet have a lot of power over that code base and so if you really want a good example of why you should care go look at the

    • requires that one person that really isn't friendly to the Internet have a lot of power over that code base

      You mean Linus?

  • by redelm ( 54142 ) on Thursday February 06, 2025 @03:17PM (#65147783) Homepage

    If the mix is bad, maybe C is the problem? =ducks=

    • by Junta ( 36770 )

      I know this was for funny, but it would be a valid stance if the project were originally in Rust and C people demanded a better interface.

      That's really the issue, that for now, the project is a C based project with some Rust, and thus the onus is on the Rust to live in the ecosystem. Maybe one day it flips if the Rust people make a lot of progress, but right now the lay of the land is straightforward and inconsistent with the request.

  • by RitchCraft ( 6454710 ) on Thursday February 06, 2025 @03:28PM (#65147813)

    Mixing Rust with AL would be even more problematic, especially if you're a hot head Kernel maintainer.

  • ... I wonder how keen the fanboys would be to have C code included in it.

    Hmmm.... tricky one...

  • by rossdee ( 243626 ) on Thursday February 06, 2025 @03:55PM (#65147897)

    Did they test it on mice?

  • A recent double-blind study shows an increased risk for several types of cancer among kernel developers that use rust. This may be due to high levels of lead and other carcinogens in the actual rust that the language uses.

  • Rust, by itself, in theory, I personally don't have an issue with.

    The tooling, however? Has been nothing but an absolute clusterfuck.

    If you're Windows/Linux/MacOS on x86, you're great! Rust compiler will support you really well. But as soon as you're outside of this ecosystem, things start to turn to shit. Aarch64 isn't too bad, but beyond that, things go downhill really quick.

    Sure, the overwhelming desktop and laptop world falls into this. But that's just end-user devices. Linux runs on a shitton more thin

  • CoC violation? (Score:5, Insightful)

    by Murdoch5 ( 1563847 ) on Thursday February 06, 2025 @04:36PM (#65148019) Homepage
    How is not wanting your project to go to hell, and becoming impossible to work on, a code of conduct violation? He's absolutely right, that if you want to interface another language or framework into an existing system, do the work on the new side, don't shim the old.
  • It really seems like Hellwig is ideologically against any language other than C in the kernel and is pushing back on that principle alone.

    There's no technical argument against the patch. Hellwig isn't being asked to maintain or work on any Rust code.

    It doesn't even seem to be against Rust as a language.

    It's basically a hard line of not allowing anything other than C in the kernel.

    Agree or disagree about that position, but that really seems like what it is.

  • You've got a huge, heavily tested code base that's decades old, full of myriad edge cases and weird cruft but it works correctly. It's built in an old language that starts with a "C".

    Changing it correctly would require documenting all the requirements, building 20 million test cases, and require people skilled in the existing language and the new language, and they need to be highly conversant in both. And dealing with unexpected hurdles that couldn't be foreseen by the world's top programmers, like the mai

  • Having Cmake, Make, Python, Perl, Bash and God knows what else just to build a project is already a nightmare. Too many languages in the build system already makes jumping in and being effective on a software project pretty tough. On top of that, having assembler, C, C++, and perhaps Ada or now Rust in a system software project means to contribute you often have to be reasonably competent in all the language AND have all the necessary toolchains installed.

    The Linux kernel project's handling of Rust is prett

  • From a month and a half ago, a post about Rust [9cache.com].

    This story is exactly that.

  • Firstly, if you are a kernel programmer, you shouldn't have a problem learning to read Rust if needed.

    This isn't where the argument is. Well, that is exactly where the argument is, but not for the simple reasons you think.

    Linux is famous for not having standardized internal ABIs in a lot of areas. Some see this as a critical to Linux being an success, other see it as a impediment to progress.

    As far as Linus goes, he doesn't see any problem with Rust in the kernel, so it goes down the chain.

    As I see it, this

"But this one goes to eleven." -- Nigel Tufnel

Working...