\

Linux 0.11 rewritten in idiomatic Rust, boots in QEMU

81 points - yesterday at 8:11 PM

Source
  • prologic

    yesterday at 9:54 PM

    I just compared this Rust implementation against the original C sources. Some ~50k SLOC (Rust) compared to maybe ~8-12k SLOC of C (depending on if you count headers). Why is the Rust implementation so much more complex and onerous?

      • josephg

        yesterday at 10:07 PM

        If the readme is anything to go by, this doesn't look like it was written by hand. Codex if I were to guess. I wonder the coding agent "improved" the code.

        The readme hints at the prompt:

        > It keeps the original system's semantics — what it does — while rethinking how it's expressed: stronger types, clearer module boundaries, idiomatic abstractions everywhere.

        "idiomatic abstractions" would certainly bloat the line count.

          • rtpg

            yesterday at 11:13 PM

            kinda sad cuz 10klines you really get into "well I can just sit there and bang at the problem by hand" territory.

            Sounds like a fun project....

              • goalieca

                yesterday at 11:20 PM

                Linux at that point’s whole purpose was to bang at it by hand and learn something. There’s a ton of irony in having an LLM do it.

            • pydry

              yesterday at 11:48 PM

              so, slop

          • steveklabnik

            yesterday at 10:32 PM

            For fun, I decided to take a look at a random syscall: fork.

            * https://github.com/yuan-xy/Linux-0.11/blob/master/kernel/for...

            * https://github.com/Poseidon-fan/linux-0.11-rs/blob/420152fdf...

            The Rust is slightly shorter, though it also isn't organized in exactly the same way. The code isn't that different overall, creating and copying some data structures around, as you'd expect for a fork implementation of this vintage.

            Maybe I got lucky, but I would expect that it's more of what other people said: this repository includes far more than the kernel.

            • dminik

              yesterday at 10:05 PM

              According to this breakdown: https://ghloc.vercel.app/Poseidon-fan/linux-0.11-rs?branch=m...

              It's about 15k lines of code for the kernel and the rest is various utilities, libraries and programs that can run on the kernel.

                • dminik

                  yesterday at 10:13 PM

                  Also, after a quick look at a few files, the rust version appears to be much more commented. Not sure if that makes up the extra several thousand lines, but surely counts accounts for some of that.

                    • cozzyd

                      yesterday at 10:20 PM

                      SLOC should omit comments no?

              • Aurornis

                yesterday at 10:56 PM

                This repo contains a lot of extra tools and userspace programs.

                The majority of Rust the code in the repo is not for the Linux kernel.

                • binsquare

                  yesterday at 9:58 PM

                  I don't think it's rust

                  • ls-a

                    yesterday at 10:30 PM

                    I like how everyone has a different theory as to why

                    • icemanx

                      yesterday at 10:27 PM

                      because of AI

                      • broknbottle

                        yesterday at 9:58 PM

                        More LoC means easier to quantify the impact when telling a story. The actual code quality may be lower but that’s the schmuck’s problem that comes after once promo is acquired.

                          • 3836293648

                            yesterday at 10:09 PM

                            Or, as others have already noted, it's only about 15k and the repo includes tools and test programs.

                            • newtonianrules

                              yesterday at 10:05 PM

                              I’ve never worked with Silicon Valley people before now, and now I get why so many projects are abandoned and rewritten when they could just use open source. The whole culture is promo driven.

                          • sudb

                            yesterday at 9:58 PM

                            One of the tradeoffs of Rust is its verbosity I think (in return for which Rustaceans would say you gain explicitness).

                              • coldtea

                                yesterday at 10:16 PM

                                Verbosity compared to C?

                                Only in extra syntax constructs.

                                But Rust can absolutely do the same thing as C in fewer lines, especially when comparing each's standard features like string support.

                                • 9dev

                                  yesterday at 10:28 PM

                                  I absolutely despise that C convention if abbreviating absolutely every single thing as much as possible. Yeah yeah, that was necessary back in the day when memory was scarce and editors were awful, but come on those days were almost half a century ago by now.

                                  Rust may be verbose, but at least you can read it without turning into a cynical greybeard subject matter expert first.

                                    • FpUser

                                      today at 12:20 AM

                                      >"Rust may be verbose, but at least you can read it without turning into a cynical greybeard subject matter expert first."

                                      Actually stuff like fn, mut etc. feels like mutilation to me.

                                      • hughw

                                        yesterday at 10:35 PM

                                        I've found that the less real estate my eyes need to scan, the faster I understand the code, even if its more tersely expressed and requires a little decoding. Relatedly, I've come to appreciate a line of code that does the thing rather than one that calls a function whose name might express what the function does, but I might need to go find it and and read its code. That works well if your language supports a terse expression. So I prefer you tersely multiply/reduce a list rather than call a function, but some languages just aren't friendly to that and demand verbosity.

                                          • doginasuit

                                            yesterday at 10:52 PM

                                            This is why kotlin is so amazing, unusually concise and unusually clear in meaning.

                                        • rcxdude

                                          yesterday at 11:13 PM

                                          Rust does so a lot of abbreviation, though. fn, ptr, mut, etc.

                                          • skydhash

                                            yesterday at 10:59 PM

                                            I kinda love it, because verbosity means you have to rely on completion and that has a negative impact on retention.

                                            And the terseness is good when you’re familiar with the code.

                                • mjhay

                                  yesterday at 10:20 PM

                                  I used to like rust, but I feel like I’m being Pavlovian-conditioned to recoil at its mention now.

                                    • Aurornis

                                      yesterday at 11:00 PM

                                      This is Linux 0.11 from 1991.

                                      Someone is having fun with a side experiment that has no practical real-world implications.

                                      This stuff is supposed to be fun and we should celebrate when other people are doing fun, pointless things like this. If you're interested then ignore it and move on. There's no need to get involved or comment if a project of no consequence is uninteresting to you personally

                                      • Krutonium

                                        yesterday at 10:22 PM

                                        I still like it. People are having fun playing with their toy and tool. I have no problem with that.

                                          • mjhay

                                            yesterday at 10:27 PM

                                            I shouldn’t have been so negative. I still very much like Rust, but hearing about these AI rewrites constantly is tiresome.

                                              • willx86

                                                yesterday at 11:12 PM

                                                I'd prefer reading about a rust rewrite then a saas paas CMS integration web thing on the latest framework It'll probably go nowhere, but it's cool to see people test the limits of what they can do and I can't watch without spending a penny

                                                Kinda like jackass, fascinating to watch but damn I do not want to do it

                                            • fsckboy

                                              yesterday at 10:26 PM

                                              People are having fun with AI coding, and I have no problem with that, but I am sick of hearing about it.

                                          • block_dagger

                                            yesterday at 10:32 PM

                                            I have the opposite feeling; I am liking Rust more and more and thinking most of the world's C code should be rewritten. It seems like a sweet spot of enforced memory safety, performance, and human/agent readability.

                                              • skor

                                                yesterday at 10:43 PM

                                                why rewrite if you can check for and fix bugs? If you are thinking of AI fixing bugs is less expensive

                                                  • minimaxir

                                                    yesterday at 10:55 PM

                                                    Memory bugs are unknown unknowns that AI may or may not catch. There's net-present-value in switching to a language where certain types of memory bugs are impossible.

                                                    • insanitybit

                                                      today at 12:01 AM

                                                      > If you are thinking of AI fixing bugs is less expensive

                                                      Because I don't think this. A rewrite is cheaper to me.

                                                      • ImaCake

                                                        yesterday at 10:54 PM

                                                        I guess ask the bun people why they translated from zig to rust. I think it was essentially because rust guarantees a set of bugs can't exist so over medium to long term timeframes you end up with less technical debt.

                                                • treyd

                                                  yesterday at 11:23 PM

                                                  Can you elaborate on what causes that reaction specifically?

                                                  • minimaxir

                                                    yesterday at 10:28 PM

                                                    Of all the tools in software engineering to be overpopular and overused, Rust is an instance where that is a very good thing.

                                                    Atleast people aren't AI rewriting things into PHP.

                                                      • vlod

                                                        yesterday at 10:32 PM

                                                        Be careful, that sounds almost like a dare...

                                                • bijowo1676

                                                  yesterday at 11:10 PM

                                                  The ultimate boss of Rust rewrites. Very happy that LLM assisted coding unlocks these kind of projects

                                                  • broodbucket

                                                    yesterday at 10:34 PM

                                                    I hate that 5 years ago I'd see a headline like this and think it was awesome, and now it's just "look at what someone's spent tokens on today"

                                                      • encyclopedism

                                                        yesterday at 11:01 PM

                                                        Written by AI and not nearly as impressive at all. Such a shame because I thought someone had spent real time and effort producing this. The output is commoditised and now neither important nor precious. Damn near anyone could repeat it.

                                                          • minimaxir

                                                            yesterday at 11:17 PM

                                                            To paraphrase another comment (https://news.ycombinator.com/item?id=48900086), this project is fun and fun should be encouraged, as experimentation is what leads to more innovative things. The existence of this project doesn't take away from anything.

                                                              • broodbucket

                                                                yesterday at 11:42 PM

                                                                I don't think it's wrong to do this and I'm glad it's fun for some, it's just not the same as seeing a project like this that was human authored

                                                    • jagged-chisel

                                                      yesterday at 10:53 PM

                                                      How do the binary sizes compare? An original Linux 0.11 kernel vs. this oxidized version.

                                                        • xedrac

                                                          yesterday at 11:13 PM

                                                          If it's written with nostd, I'd expect them to be similar.

                                                            • jagged-chisel

                                                              today at 12:20 AM

                                                              That is indeed the expectation. But what’s the reality?

                                                      • xqb64

                                                        yesterday at 9:56 PM

                                                        Slopware?

                                                          • bryanlarsen

                                                            yesterday at 10:09 PM

                                                            Presumably, but exactly the sort of project where slopware is appropriate. Nobody is expected to use it.

                                                              • computerdork

                                                                yesterday at 10:37 PM

                                                                Haha, well, maybe a couple dozen grad students creating some unusual extension to the os:)

                                                        • devy

                                                          yesterday at 10:22 PM

                                                          Docs full of emojis, this is another AI slop?!

                                                          Tangential note: there is already a community effort[1] to rewrite GNU commandline tools into Rust and Canonical shipped the rust version of the /bin/utils in Ubuntu 26.04 Resolute Raccoon by default[2] in their "oxidizing" initiative.[3]

                                                          PS: Linus Torvalds has confirmed that the existing Linux kernel will never be fully rewritten in Rust.[4] Let's see how well that statement age.

                                                          [1]: https://github.com/uutils/coreutils

                                                          [2]: https://canonical.com/blog/canonical-releases-ubuntu-26-04-l...

                                                          [3]: https://discourse.ubuntu.com/t/carefully-but-purposefully-ox...

                                                          [4]: https://news.ycombinator.com/item?id=41355731

                                                            • lioeters

                                                              yesterday at 10:53 PM

                                                              As soon as Linus retires, there will be an initiative to rewrite the Linux kernel in Rust assisted by LLMs. Either that, or some company will fund a fork before that. Imagine, man pages full of emojis!

                                                                • steveklabnik

                                                                  yesterday at 10:55 PM

                                                                  Linus is supportive of Rust and uses LLMs.

                                                                  The reasons to not have a full-Rust Linux kernel are over more important, real engineering things. (Platform support being the big one.)

                                                                    • JoshTriplett

                                                                      yesterday at 11:17 PM

                                                                      > Platform support being the big one.

                                                                      And between rustc_codegen_gcc, projects like https://github.com/FractalFir/crustc, the ongoing addition of backends to LLVM and Rust, and the eventual removal of obsolete targets as hardware goes away, that's less and less of a problem.

                                                                        • steveklabnik

                                                                          yesterday at 11:22 PM

                                                                          I certainly don't think it'll be a barrier forever, for sure.

                                                                      • xedrac

                                                                        yesterday at 11:15 PM

                                                                        Since the Rust support in the kernel is not optional, it already has an impact on platform support, no? Or maybe they are using the gnu toolchain to avoid that?

                                                                          • JoshTriplett

                                                                            yesterday at 11:20 PM

                                                                            Rust support in the kernel is still optional; it's currently only allowed in drivers, and drivers only use Rust if they can accept running only on current Rust targets (which is not a substantive limitation).

                                                                            I expect Rust to eventually get used in the core kernel, or in drivers that everyone wants to use (e.g. some new bus or device on most new hardware), but I expect that by the time that happens the set of targets supported by the kernel and the set of targets supported by Rust (including through things like crustc and codegen_gcc) will have converged sufficiently.

                                                                        • lioeters

                                                                          yesterday at 10:59 PM

                                                                          [dead]

                                                              • drnick1

                                                                yesterday at 10:51 PM

                                                                How does the performance compare?

                                                                • richard_todd

                                                                  yesterday at 10:38 PM

                                                                  Honestly -- and I know this project is just a toy/fun experiment -- with modern AI, I think this is the correct approach to Rust-ifying projects. Just fork it and do an AI-assisted wholesale conversion, and run in parallel for a while to make sure all the regressions are found. Then you can compare to the original for benefits and drawbacks, and you get a more idiomatic code-base... instead of trying to convince longstanding projects to go into a half-rust Frankenstein model, which is what I usually see.

                                                                  • yesterday at 9:40 PM

                                                                    • irishcoffee

                                                                      yesterday at 10:24 PM

                                                                      What is “un-idiomatic” rust?

                                                                        • steveklabnik

                                                                          yesterday at 10:29 PM

                                                                          With a project like this, I would expect that "idiomatic Rust" means "attempting to write as much safe code as is reasonably possible" rather than "translating the C to Rust directly".

                                                                      • rvz

                                                                        yesterday at 9:48 PM

                                                                        Nice project, with so many emojis at the start of every title of the README.

                                                                        Wonder who could have done that?

                                                                          • fpauser

                                                                            yesterday at 11:47 PM

                                                                            ;)

                                                                        • xyst

                                                                          yesterday at 10:02 PM

                                                                          rewriting {PROGRAM} in rust is so fetch.

                                                                            • sajithdilshan

                                                                              yesterday at 10:08 PM

                                                                              Stop trying to make fetch happen

                                                                                • larkost

                                                                                  yesterday at 11:10 PM

                                                                                  I worked for Fetch Robotics (now defunct), and there were a bunch of people (especially in management) who would constantly reference the Mean Girls "stop trying to make fetch happen" line in company-wide slideshows.

                                                                                  A couple of times it was cute... but they took it too far in my opinion. And sadly the company was bought out, and now they too have decides to "stop trying to make Fetch happen" (yes, officially it was bought out, but not for the actual robots part).

                                                                                  • tialaramex

                                                                                    yesterday at 10:30 PM

                                                                                    They actually did make fetch happen. Once upon a time it was usual in Javascript to use a thing called XMLHttpRequest which despite its name isn't actually for XML, it's just that XML was a big deal when it was created. The replacement API for making normal HTTP requests is just named fetch, and it was "new" so long ago that popular web browsers had versions like 40 rather than 150.

                                                                                    That movie is so old it's entirely possible that it's just named "fetch" because that's a reasonable thing to call this feature and so it's a coincidence, but I do like to think that at least some people at WHATWG were quoting Mean Girls...

                                                                                      • sscaryterry

                                                                                        yesterday at 10:34 PM

                                                                                        Wait? You guys have fetch?

                                                                            • globalnode

                                                                              yesterday at 11:53 PM

                                                                              rust evangelism is some people / youth of today trying to differentiate themselves from their parents, aka heavy metal of programming. its ok, its fun. i cant read their source code but i dont need to, theres a whole world out there of c/c++/python stuff that will get the job done faster and with less hassle.