Most active commenters

    ←back to thread

    277 points love2read | 11 comments | | HN request time: 0.423s | source | bottom
    1. zoom6628 ◴[] No.42477991[source]
    I wonder how this compares to the zig-to-C translate function.

    Zig seems to be awesome at creating mixed environs of zig for new code and C for old, and translating or interop, plus being a C compiler.

    There must be some very good reasons why Linux kernel maintainers aren't looking to zig as a C replacement rather than Rust.

    I don't know enough to even speculate so would appreciate those with more knowledge and experiencing weighing in.

    replies(6): >>42478032 #>>42478047 #>>42478054 #>>42478657 #>>42479251 #>>42480130 #
    2. capitol_ ◴[] No.42478032[source]
    Maybe because zig isn't memory safe.
    3. ChristianJacobs ◴[] No.42478047[source]
    > looking to zig as a C replacement rather than Rust

    Rust isn't a "replacement for C", but an addition to it. It's a tool that Torvalds et. al. has recognised the value of and thus it's been allowed in the kernel. The majority of the kernel code will still be written in C.

    I'm no kernel maintainer, but I can speculate that two of the main reasons for Rust over Zig are the compile time guarantees that the language provides being better as well as the rate of adoption. There is a lot of work done by many leading companies in the industry to provide Rust native code or maintained Rust bindings for their APIs. Windows devs are re-writing parts of _their_ kernel in Rust. There's a "movement" going on that has been going on for a while. I only hope it doesn't stop.

    Maybe the maintainers feel like Zig doesn't give them enough over C to be worth the change? Many of them are still opposed to Rust as well.

    replies(2): >>42478139 #>>42478241 #
    4. spiffyk ◴[] No.42478054[source]
    Zig is nowhere near mature enough to be considered for the kernel yet. There are breaking changes to it regularly still - which is a good thing for Zig now, but not so good for huge, long-lived codebases like Linux. Also compiler bugs happen.

    Saying this as someone who generally likes Zig's direction.

    5. DonaldPShimoda ◴[] No.42478139[source]
    > Rust isn't a "replacement for C"

    Hmm I think to clarify I would say that Rust _is_ intended as a replacement for C in general, but that this isn't how the Linux kernel developers are choosing to use it.

    As for why the kernel developers would choose Rust, I would think another one of the primary benefits is that the type system guarantees the absence of a wide class of memory-related errors that are prevalent in C, and this type system (as well as those of its predecessors) has been subjected to significant scrutiny by the academic community over the last couple of decades to help iron out problems. I suspect this is also part of why Rust has a relatively large and passionate community compared to other C alternatives.

    replies(1): >>42478360 #
    6. josefx ◴[] No.42478241[source]
    > It's a tool that Torvalds et. al. has recognised the value of and thus it's been allowed in the kernel.

    Has there actually been a successfull contribution to the mainline kernel? The last two big projects I heard of (ext2 / Apple drivers) seemed to have issues getting their code accepted.

    replies(1): >>42478840 #
    7. burakemir ◴[] No.42478360{3}[source]
    Agreed. The large and passionate community may have multiple factors but "things actually work" is probably a factor.

    It is hard to get a full picture of how academic research influenced Rust and vice versa. Two examples:

    - The use of linearity for tracking ownership in types has been known to academics but had never found its way into a mainstream language.

    - researchers in programming language semantics pick Rust as a target of formalization, which was only possible because of design choices around type system. They were able to apply techniques that resulted from decades of trying to get a certified C. They have formalized parts of the standard library, including unsafe Rust, and found and fixed bugs.

    So it seems fair to say that academic research on safety for C has contributed much to what makes Rust work today, and in ways that are not possible for C and C++ because these languages do not offer static guarantees where types Transport information about exclusive access to some part of memory.

    8. 3836293648 ◴[] No.42478657[source]
    Zig isn't 1.0 and has zero backcompat guarantees. It's also barely used anywhere and hasn't proven its value, even if parts of it may seem promising
    9. shakna ◴[] No.42478840{3}[source]
    rnull is in the kernel. And I believe one of the generic Realtek drivers is Rust as well.
    10. devjab ◴[] No.42479251[source]
    As I understand it most kernel maintainers aren’t looking to replace C with anything.

    Zig has much better interoperability with C than Rust, but it’s not memory safe or stable. I think we’ll see quite a lot of Zig adoption in the C world, but I don’t think it’s in direct competition with Rust as such. In my region of the world nobody is adopting Rust, the C++ people are remaining in C++. There was some interest in Rust originally but it never really caught on in any company I know of. Likely for the same reason Go has become huge in younger companies but will not really make its way into companies which are traditionally Java/C# because even if it made sense technically (and it probably doesn’t) it’s a huge change management task. Zig is seeing traction for programs without the need for dynamic memory allocation, but not much beyond that.

    11. Ar-Curunir ◴[] No.42480130[source]
    Rust is stable and used by a number of big players, while Zig is not stable, and as a result hasn’t seen widespread adoption yet