LWN: Comments on "Standards for use of unsafe Rust in the kernel" https://lwn.net/Articles/982868/ This is a special feed containing comments posted to the individual LWN article titled "Standards for use of unsafe Rust in the kernel". en-us Thu, 04 Sep 2025 19:26:26 +0000 Thu, 04 Sep 2025 19:26:26 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Valid structures and bugs https://lwn.net/Articles/988158/ https://lwn.net/Articles/988158/ farnz <p>That's part of what I mean by "change the way you think"; if you've designed your filesystem such that constructs that are valid in isolation result in kernel bugs when combined, you have a problem. If you merely have a situation where the kernel remains bug-free, but there's data loss on a corrupt filesystem due to the conflicting structures (e.g. two inodes sharing an extent record means that either inode can modify that extent record), then you don't have a problem. <p>And part of this is distinguishing severities of bug; a filesystem bug that gives me total control of your machine because a consequence of an impossible construct being present is that the kernel jumps to an attacker-controller address is a different type of bug to one where the filesystem, when faced with a corrupted filesystem image, corrupts it further. Sun, 01 Sep 2024 09:26:59 +0000 WUFFS and the Linux kernel https://lwn.net/Articles/988094/ https://lwn.net/Articles/988094/ pizza <div class="FormattedComment"> <span class="QuotedText">&gt; Part of the point of languages like WUFFS is to change the way you develop software that handles potentially dangerous inputs; instead of trying to validate on the fly, </span><br> <p> For filesystems, you still have to validate on the fly. Because there are constructs that are valid in isolation but conflict with each other. You have to validate (and maintain) the _entire_ state holistically, and that is not practical when your metadata alone can easily exceed your memory size.<br> <p> <p> <p> <p> <p> <p> <p> </div> Sat, 31 Aug 2024 17:30:09 +0000 WUFFS and the Linux kernel https://lwn.net/Articles/988089/ https://lwn.net/Articles/988089/ farnz <p>I did indeed mean 2**(2**44), since I have a 2 TiB exposed capacity drive (no idea how much raw capacity there is) - it's a huge number of possible states. And if I understated the number, that just makes it worse - the underlying issue that WUFFS and friends aim to help you with is reducing the number of input states from "all possible bit patterns" to "valid bit patterns", by forcing you to provide functions from "possible bit pattern" to "valid bit pattern or error state". Sat, 31 Aug 2024 17:18:08 +0000 WUFFS and the Linux kernel https://lwn.net/Articles/988064/ https://lwn.net/Articles/988064/ sammythesnake <div class="FormattedComment"> <span class="QuotedText">&gt; there's around 2**44 possible states for my SSD's exposed storage areas</span><br> <p> You have a 44 bit SSD? [scratches head]<br> <p> Did you perhaps mean something like 2**2**44 (which by my quick stab at calculating corresponds to a ~2TB drive)<br> </div> Sat, 31 Aug 2024 15:26:35 +0000 Banning unsafe in Rust for Linux device drivers https://lwn.net/Articles/988035/ https://lwn.net/Articles/988035/ sammythesnake <div class="FormattedComment"> Reddit has a handy relative of this (though I don't think history is visible(?)) Edits are noted with something like "last edited at [time]" unless made within some small grace period after the initial post, because:<br> <p> <span class="QuotedText">&gt; most people spot their mistakes as they click "post" :-)</span><br> <p> This is *absolutely* the case for the overwhelming majority of edits I'd like to make to *my* posts/comments :-/<br> </div> Sat, 31 Aug 2024 11:22:53 +0000 The Tower https://lwn.net/Articles/987598/ https://lwn.net/Articles/987598/ atnot <div class="FormattedComment"> I think most of her blog posting energy goes into the axo.dev blog now, e.g. <a href="https://blog.axo.dev/2024/07/an-app-by-any-other-name">https://blog.axo.dev/2024/07/an-app-by-any-other-name</a><br> </div> Thu, 29 Aug 2024 09:18:28 +0000 The Tower https://lwn.net/Articles/987559/ https://lwn.net/Articles/987559/ amarao <div class="FormattedComment"> Btw, why did she stop posting? It was really interesting blog.<br> </div> Wed, 28 Aug 2024 18:48:55 +0000 Null reference as insta-UB https://lwn.net/Articles/986749/ https://lwn.net/Articles/986749/ farnz <p>That's why I said references must point to a valid <em>place</em>, not a valid instance. It's entirely permissible for the place that's pointed at to not be a valid instance, as long as it's a valid place for the referent type to live in. Thu, 22 Aug 2024 08:11:23 +0000 The Tower https://lwn.net/Articles/986717/ https://lwn.net/Articles/986717/ jsakkine Your suggestion is based on an imaginary topology that does not exist. Right of the bat, these attributes affecting the topology come to mind: <ul> <li>The top-most commit ID</li> <li>Kernel config</li> <li>CPU architecture</li> </ul> Subsystem maintainers will do always only what is best for that particular subsystem. Wed, 21 Aug 2024 22:37:06 +0000 Null reference as insta-UB https://lwn.net/Articles/986722/ https://lwn.net/Articles/986722/ mb <div class="FormattedComment"> Ok, I guess I don't understand your original posting then.<br> </div> Wed, 21 Aug 2024 22:22:00 +0000 Null reference as insta-UB https://lwn.net/Articles/986721/ https://lwn.net/Articles/986721/ riking <div class="FormattedComment"> The validity invariant is the things that unsafe code can't ever do. The safety invariant is the things it can be careful about and can't let escape to uncontrolled safe code.<br> </div> Wed, 21 Aug 2024 22:07:00 +0000 Null reference as insta-UB https://lwn.net/Articles/986706/ https://lwn.net/Articles/986706/ mb <div class="FormattedComment"> But this is only true for "initialized". Even unsafe is not allowed to construct null-references.<br> </div> Wed, 21 Aug 2024 21:14:15 +0000 Null reference as insta-UB https://lwn.net/Articles/986697/ https://lwn.net/Articles/986697/ riking <div class="FormattedComment"> Note: "references must point to a valid instance of the object" is actually the safety invariant. The validity invariant is "initialized, non-null, aligned to the alignment of the object".<br> <p> (What does that mean? It means that unsafe code can temporarily hold references that don't point to valid objects as long as it's careful what it does with them (doesn't try to read) and doesn't let the reference escape into safe code not controlled by the author of the unsafe code.)<br> </div> Wed, 21 Aug 2024 20:38:37 +0000 Banning unsafe in Rust for Linux device drivers https://lwn.net/Articles/986694/ https://lwn.net/Articles/986694/ riking <div class="FormattedComment"> You need to pair this with delaying email notifications until just after the edit period has expired.<br> </div> Wed, 21 Aug 2024 20:25:31 +0000 Rust and UB https://lwn.net/Articles/986329/ https://lwn.net/Articles/986329/ ralfj <div class="FormattedComment"> Then I hope someone will invest in improving the compilers here. :) I'm not enough of an expert for these low-level parts to judge how much performance they are leaving on the table. But this is simply not something that can be reliably fixed at higher levels of abstraction.<br> <p> Do you know if there's a bug report against GCC and LLVM discussing the correctness and feasibility of such optimizations?<br> </div> Tue, 20 Aug 2024 06:35:31 +0000 Maybe this is enough? https://lwn.net/Articles/986226/ https://lwn.net/Articles/986226/ corbet So this has gone on for quite some time; I don't think any minds will be changed at this point. Maybe time to wind it down? <p> Thank you. Mon, 19 Aug 2024 14:17:54 +0000 Java/C# vs Rust https://lwn.net/Articles/986198/ https://lwn.net/Articles/986198/ khim <p><font class="QuotedText">&gt; New stuff only rarely replaces the old stuff; instead it's layered on top. It's turtles all the way down.</font></p> <p><font class="QuotedText">&gt; And again, it is a simple FACT that Java is vastly more approachable than the stuff it supplanted</font></p> <p>Can you stop contradicting yourself at least in two adjacent sentences?</p> <font class="QuotedText">&gt; Multiple generations of ARM processors ran the Java bytecode natively</font> <p>Nope. Few ARMv5 CPUs has the ability to run some small subset of Java bytecode. It was, basically, to run few games on some phones and for nothing else. Starting from ARMv6 only “null” implementation of <a href="https://en.wikipedia.org/wiki/Jazelle">Jazelle</a> is supported.</p> <p>So that's <b>another</b> example of pointless waste (thankfully very limited compared to the damage caused by the large C#/Java crazyness).</p> <font class="QuotedText">&gt; Completely supplanting Pascal in introductory programming courses</font> <p>Yeah. And also Scheme in some course. <b>Another</b> negative.</p> <font class="QuotedText">&gt; That was a *HUGE* change over the former status quo.</font> <p>Where do you see me objecting? Sure, C#/Java caused <b>lots</b> of changes. <b>Almost all of them negative</b>.</p> <p>But you are arguing as if I'm objecting about magnitude of change… I'm not! C#/Java caused absolutely huge <b>negative</b> change.</p> <p>There were, also, some minuscule positive changes, sure, but compared to problems that C#/Java craze caused they are hard to even notice.</p> <font class="QuotedText">&gt; Sure, many of its use cases have since been better served with newer stuff.</font> <p>That's not important. What <b>is</b> important is that almost all use cases are better served by <b>older</b> stuff.</p> <font class="QuotedText">&gt; Isn't that the fate of all technology?</font> <p>Sure. But C#/Java is different: that's the rare case where bad technology was replaced with worse one.</p> <p>Wanted to say that it's the only such change, but nope, there are many other like that: solar and win power plants, electric cars, etc. That have only started happening recently. About quarter century ago. But, sadly, it's not limited to IT and not limited to C#/Java. True.</p> <p>But the fact that was achieved by temporary disconnect between feasibility of technology and availability of funding doesn't make that change <b>good</b> and we <b>would</b> pay for that stupidity, and, it looks like, rather sooner than later.</p> <p>Microsoft and Sun have already paid the price, but I doubt it would be limited to that.</p> Mon, 19 Aug 2024 13:39:19 +0000 Java/C# vs Rust https://lwn.net/Articles/986197/ https://lwn.net/Articles/986197/ pizza <div class="FormattedComment"> <span class="QuotedText">&gt; No matter how you look on it the whole thing it looks like a net negative to me: we haven't gotten any tangible benefits from that rewrite </span><br> <p> Wait, _rewrite_? Surely you jest. <br> <p> New stuff only rarely replaces the old stuff; instead it's layered on top. It's turtles all the way down.<br> <p> And again, it is a simple FACT that Java is vastly more approachable than the stuff it supplanted, and was useful for nearly everything, from deeply embedded stuff [1] to teaching/toy problems [2] to desktop applications [3] to enterprise consultant wet dreams -- All from the same base tooling. That was a *HUGE* change over the former status quo.<br> <p> Sure, many of its use cases have since been better served with newer stuff. So what? Isn't that the fate of all technology?<br> <p> [1] Multiple generations of ARM processors ran the Java bytecode natively<br> [2] Completely supplanting Pascal in introductory programming courses<br> [3] Including browser applets. Which I don't miss.<br> </div> Mon, 19 Aug 2024 12:48:41 +0000 UB in Rust vs C https://lwn.net/Articles/986177/ https://lwn.net/Articles/986177/ intelfx <div class="FormattedComment"> <span class="QuotedText">&gt; tive fix for the billion dollars mistake, essentially. References, in Rust, couldn't be null, attempting to create such a reference is an instant UB</span><br> <p> Here you're just restating the question and handwaving vigorously. This is not an answer.<br> <p> <span class="QuotedText">&gt;but Option&lt;&amp;T&gt; can hold None and, more importantly, it's guaranteed that in-memory representation for None in Option&lt;&amp;T&gt; is the exact same thing as null in pointer and it's even guaranteed that it would be the same as null in pointer used by C on that platform!</span><br> <p> Okay, yeah, so if I correctly understand what you are trying to say here, it's to make niches optimization possible. I didn't think of it.<br> </div> Mon, 19 Aug 2024 00:34:50 +0000 Java/C# vs Rust https://lwn.net/Articles/986136/ https://lwn.net/Articles/986136/ khim <font class="QuotedText">&gt; ...So billions of lines of inherently memory-safe code deployed onto commodity systems never happened?</font> <p>Of course they happened! Billions of lines of code <b>already written</b> is various memory-safe language (from COBOL and Clarion to Visual Basic and FoxPro) were, with great pains, rewritten in two other, <b>more resource hungry</b> memory safe languages.</p> <p>Yes, these languages never have been using “managed code” or “tracing garbage collection”, but they were perfectly memory safe and they worked perfectly fine.</p> <p>No matter how you look on it the whole thing it looks like a net negative to me: we haven't gotten any tangible benefits from that rewrite (although some industries have gotten rich, that's true, but that's like burning the house to heat a stew), code that was before than “grand revolution” written in memory safe languages was still written in memory safe languages (only now with lots of more unneeded complexity) and code written in non-memory safe languages continued to use non-memory safe languages.</p> Sun, 18 Aug 2024 14:55:11 +0000 Java/C# vs Rust https://lwn.net/Articles/986133/ https://lwn.net/Articles/986133/ pizza <div class="FormattedComment"> <span class="QuotedText">&gt; Java have diverged the industry, made it waste trillions of dollars on mirage that never materialized</span><br> <p> ...So billions of lines of inherently memory-safe code deployed onto commodity systems never happened?<br> </div> Sun, 18 Aug 2024 13:58:12 +0000 Java/C# vs Rust https://lwn.net/Articles/986132/ https://lwn.net/Articles/986132/ khim <font class="QuotedText">&gt; Lisp machines and AS/400s were about as far removed from commodity systems as it could get, and were effectively unobtanium for mere mortals.</font> <p>And how is that <b>a bad thing</b>? They were solving programs that either are not needed by mere mortals or are not solved by Java.</p> <p>Java managed to [ab]use managed code but failed to achieve thing that managed code is really good for: forward compatibility. While AS/400 doesn't even give you an ability to execute in native code it's not uncommon for a Java program to code with it's own version of JRE because it may misbehave with any other version and conversion between .NET 1.x, 2.x and .NET core is pretty damn non-trivial.</p> <p>Thus, in the end, C# and Java achieved intermediate goals these exotic systems achieved in pursit of worthwhile goals yet failed to achieve anything worthwhile outside of hype train.</p> <font class="QuotedText">&gt; Like it or not, Java's particular combination of features and accessibility changed the entire trajectory of the industry.</font> <p>Isn't <b>that</b> my original point? Java have diverged the industry, made it waste trillions of dollars on mirage that never materialized, sent it into a dead end, and now we would need to spend more trillions of dollars to undo all that damage.</p> <p>Hardly something to celebrate.</p> Sun, 18 Aug 2024 13:35:24 +0000 Java/C# vs Rust https://lwn.net/Articles/986131/ https://lwn.net/Articles/986131/ pizza <div class="FormattedComment"> <span class="QuotedText">&gt; Sure, Java have shown that you may develop things in a managed code, but List machines did that before Java. Java have shown that you may write portable code but AS/400 did that before.</span><br> <span class="QuotedText">&gt;None of achievements that Java may show are new and the ones that are new are completely unrelated to these things that Java was supposed to achieve.</span><br> <p> Congratulations, you just demonstrated my point.<br> <p> Lisp machines and AS/400s were about as far removed from commodity systems as it could get, and were effectively unobtanium for mere mortals.<br> <p> ...Unlike Java, which you could obtain for low-to-zero cost and could run on the systems you already had. <br> <p> Like it or not, Java's particular combination of features and accessibility changed the entire trajectory of the industry.<br> </div> Sun, 18 Aug 2024 12:58:49 +0000 Java/C# vs Rust https://lwn.net/Articles/986130/ https://lwn.net/Articles/986130/ khim <p>It looks like an attempt to draw a target around the place where arrow hit.</p> <p>Of course if you spend enough time reframing Java achievements then you can always find a way to define them in way to show that Java did <b>something</b> first.</p> <p>But premise was to achieve something pretty concrete, billions (if not trillions!) of dollars were spent in an attempt to deliver that and none of the achievements that may last needed these things.</p> <p>Sure, Java have shown that you may develop things in a managed code, but List machines did that before Java. Java have shown that you may write portable code but <a href="https://en.wikipedia.org/wiki/IBM_AS/400">AS/400</a> did that before.</p> <p><b>None</b> of achievements that Java may show are new and the ones that are new are completely unrelated to these things that Java was supposed to achieve.</p> <p>It's like these solar and wind power stations or electric cars: sure, they advanced certain narrow fields significantly, but does the damage they did to the world economy (and, ironically, to the world ecology) are worth it?</p> <p>This question is debatable but the fact that original promise of “self-sustainable development” wasn't achieved and wouldn't be achieved on this path remains. I suspect that it would be “achieved”, in the end, via sleight of hands when nuclear power would be declared “green”, too and then everyone would be happy about how “green” power works while completely forgetting decades of investment into a dead end.</p> Sun, 18 Aug 2024 12:47:00 +0000 Java/C# vs Rust https://lwn.net/Articles/986128/ https://lwn.net/Articles/986128/ pizza <div class="FormattedComment"> <span class="QuotedText">&gt; I couldn't name any single goal that Java set before itself and made better then some other language.</span><br> <p> *single* goal, no. But these goals didn't exist in isolation, and until Java came along, nothing else put them all of those "single goals" together in a way that was both accessible at the entry level (in part due to running on commodity systems) and useful at the high end.<br> <p> </div> Sun, 18 Aug 2024 12:27:00 +0000 Java/C# vs Rust https://lwn.net/Articles/986118/ https://lwn.net/Articles/986118/ khim <font class="QuotedText">&gt; Over time, the bad parts were discarded, and good parts were promoted.</font> <p>And it's just a sheer coincidence that “bad part” are exclusive for Java but “good part” are not? Really?</p> <font class="QuotedText">&gt; But even with all of its over-engineering, EJB containers like WebLogic or JBoss pioneered some of the best practices that we use even now: artifact-based deployments, monitoring and metrics, centralized logging, and even a notion of proto-containers (WARs and EARs).</font> <p>Pionered? In what sense? They raised hype around things invented by other, that's all. Syslog doesn't need Java and chroot was invented before it, too. IBM did remote monitoring for decades before Java was ever invented and <a href="https://research.google/pubs/large-scale-cluster-management-at-google-with-borg/">Google's Borg</a> never needed or used Java (it supported it, though) with <a href="https://en.wikipedia.org/wiki/Sawzall_(programming_language)">Sawzall</a> existing outside of Java, too.</p> <font class="QuotedText">&gt; Java in particular has shown that large and complicated software can be written in memory-safe languages. This was not at all a given in 90-s.</font> <p><a href="https://en.wikipedia.org/wiki/Lisp_machine">Lisp machines</a> already existed and they have shown that before Java was even dreamed of.</p> <p>I couldn't name <b>any</b> single goal that Java set before itself and made better then some other language. Even cross-platform development today is mostly happening in JavaScript/TypeScript and not in Java.</p> <p>C#/Java failed on <b>all</b> goals they set out to deliver (initial goal was to <b>replace</b> C/C++, remember? <a href="https://en.wikipedia.org/wiki/JavaStation">Javastation</a> was supposed to <b>only</b> run Java applications and <a href="https://learn.microsoft.com/en-us/archive/msdn-magazine/2004/january/code-name-avalon-create-real-apps-using-new-code-and-markup-model">Avalon</a> was supposed to <b>replace</b> Win32, not complement it).</p> <p>C#/Java were pure waste of time and <b>extremely</b> disruptive for the companies that embraced them: Sun is dead is Microsoft have lost much of it's influence, because time that they wasted on unattainable goals was used by others to leapfrog them. If you recall the behaviour of “old” Microsoft then this result is 100% positive and it's true that only C#/Java could have achieved that, but somehow I seriously doubt it was intended.</p> <p>It would be really funny if Rust would, eventually, replace C/C++. Because it's developers have never embraced that as a goal. There are lots of jokes about “rewrite it in Rust” and some fanboys even say then Rust have to replace C/C++, but actual developers are realists and always designed Rust for the perpetual coexistence with C/C++. On the contrary: Java and C# were designed for the world where <b>everything</b> (except for some low-level components) is in managed code, <b>all</b> development as happening within confines JVM/CLR (basically: commercializaion of List machines concept) and <b>all</b> software is rewritten in managed code. <b>That</b> vision failed utterly and miserably and have only consumed countless resources.</p> <p>You may point out to the success of Android, but if you read interviews with Andy Rubin, you'll see that Android embraced Java not because of it's wonderful properties, but simply because when Android was made there were lots of Java developers. If Java detour would have never happened he would have picked something else (Apple picked up Objective C because macOS uses it and it worked well for them).</p> <p>Ultimately the only thing that C#/Java detour us is that world <b>without</b> managed code is viable, while world with <b>only</b> managed code is not. Anyone with two brain cells could have predicted that on the day one, but Google have done a third attempt which is, as expected, <a href="https://blog.chromium.org/2024/06/building-faster-smarter-chromebook.html">falling apart before our eyes</a>.</p> <font class="QuotedText">&gt; Could it have happened this way? Not a chance.</font> <p>Not in a world obsessed with attempt to make <i>write code so complex that there are no obvious bugs in it</i> work, sure.</p> <p>Java is very much symptom, not a disease. Disease is that naïve belief that you may <b>replace</b> competence with tools. Planes that are losing doors and AbstractFactoryFactoryBeans come from the same root. And yes, when you traverse that road then C#/Java happens narturally. I just wish we stopped and realized that this is a wrong road to traverse before so much resources would have been wasted.</p> Sun, 18 Aug 2024 08:43:49 +0000 Banning unsafe in Rust for Linux device drivers https://lwn.net/Articles/986108/ https://lwn.net/Articles/986108/ KJ7RRV <div class="FormattedComment"> This gave me an idea: would it be feasible to actually store article and comment content in a Git repository? That way, the site could just expose an interface to get a comment file's history.<br> </div> Sun, 18 Aug 2024 01:41:26 +0000 Rust and UB https://lwn.net/Articles/986097/ https://lwn.net/Articles/986097/ pbonzini <div class="FormattedComment"> <span class="QuotedText">&gt; that *sounds* like something that the codegen backend of a compiler should take care of</span><br> <p> Indeed, but neither GCC nor LLVM even try, as far as I am aware of. <br> <p> I will check my sources more on the compiler fence vs thread fence issue.<br> </div> Sat, 17 Aug 2024 17:32:33 +0000 Java/C# vs Rust https://lwn.net/Articles/986093/ https://lwn.net/Articles/986093/ Cyberax <div class="FormattedComment"> <span class="QuotedText">&gt; That's why yes, C#/Java craze was gigantic waste of time and resources </span><br> <p> I disagree. Java in particular has shown that large and complicated software can be written in memory-safe languages. This was not at all a given in 90-s. <br> <p> And of course, the Java ecosystem had struggled a lot to formulate the best practices. <br> <p> If anyone wants to be amazed by over-engineering, just look at the EJB 1.0 standard. But even with all of its over-engineering, EJB containers like WebLogic or JBoss pioneered some of the best practices that we use even now: artifact-based deployments, monitoring and metrics, centralized logging, and even a notion of proto-containers (WARs and EARs). All starting back in 1998-1999.<br> <p> Over time, the bad parts were discarded, and good parts were promoted. It provided a great learning experience for the whole industry. Would have it been better if the industry magically got all this foreknowledge back in 1999 and avoided painful diversions into the AbstractFactoryFactoryBean territory? Sure. Could it have happened this way? Not a chance.<br> </div> Sat, 17 Aug 2024 17:22:42 +0000 Java/C# vs Rust https://lwn.net/Articles/986086/ https://lwn.net/Articles/986086/ khim <font class="QuotedText">&gt; So independent of computing resources, I think it's unlikely something like Rust could have happened in 1995.</font> <p>Oh, sure. Rust in 1995 could have been a reality only if IT industry would have picked <i>write code so simple there are obviously no bugs in it</i> way to resolve <a href="https://en.wikipedia.org/wiki/Software_crisis#History">the software crisis</a>.</p> <p>But in reality said crisis was resolved via <i>write code so complex that there are no obvious bugs in it</i> which, of course, made creation of Rust in 1995 impossible.</p> <p>It's ironic that around that time (in 1996 to be exact) Hoare <a href="https://gwern.net/doc/math/1996-hoare.pdf">wrote his article</a> where he expressed his satisfaction with the fact that this approach was seemingly working.</p> <p>And, of course, when everyone was to busy piling layers upon layers of scotch and bailing wire there weren't enough people to do research that could have given us Rust in 1995.</p> <p>We needed two more decades to realize that while “let's pile layers upon layers of scotch and bailing wire till our creations would stop crashing every few hours” approach works to create something that is useful, but then it doesn't work in the face of adversary.</p> <p>Thus yes, Rust wasn't a possibility in year 1995, but not because of hardware, rather the social issues prevented it's creation, everyone was just too busy inventing various snake oil solutions which would make programs, magically, correct even when people who write them have no idea what they are doing.</p> <p>But hardware? Hardware was perfectly “kinda ready” for it: Java was insanely heavy and slow by standards of 1995 and Rust would have been a pig, too, but Rust could have become fast when computers would have become more advanced for more optimizations to become possible, same as happened to Java.</p> <p>That's why yes, C#/Java craze was gigantic waste of time and resources — but also, probably, inevitable one. World needed these <a href="https://cybersecurityventures.com/hackerpocalypse-cybercrime-report-2016/">trillion dollars loses</a> to admit that this was the wrong turn, before that happened (as even Hoare, himself, noted) it looked as if enough layers of scotch and bailing wire may fix everything.</p> Sat, 17 Aug 2024 12:04:30 +0000 Java/C# vs Rust https://lwn.net/Articles/986082/ https://lwn.net/Articles/986082/ ralfj Rust is building on a bunch of academic Programming Languages work that just wasn't done yet in the 90s. For instance, it has taken a lot of good ideas from <a href="https://en.wikipedia.org/wiki/Cyclone_(programming_language)">Cyclone</a>. <p> So independent of computing resources, I think it's unlikely something like Rust could have happened in 1995. Sat, 17 Aug 2024 10:28:29 +0000 Rust and UB https://lwn.net/Articles/986081/ https://lwn.net/Articles/986081/ ralfj <div class="FormattedComment"> <span class="QuotedText">&gt; Yes—but not in Linux, only in QEMU. QEMU is in user space and uses the C memory model, but historically most people involved were more familiar with Linux atomics. </span><br> <p> Thanks for clarifying!<br> <p> <span class="QuotedText">&gt; My understanding is that compiler fences can be used instead of thread fences if you know that two threads only ever run on the same physical CPUs. So, as far as the compiler is concerned, they should block the same optimizations as thread fences, generating the same code apart from the fence instructions themselves. The assumptions that are made on generated instructions might be dubious in terms of portability, but they're fine with respect to data races and hence UB.</span><br> <p> Interesting. According to the standard, the only thing compiler fences do is perform synchronization with signal handlers running in the current thread. (Signal handlers are "almost" separate threads in the C++ memory model, except that compiler fences suffices to synchronize with them.)<br> <p> I'm not enough of an expert in this to say whether that model can be extended to "other threads running on the same physical CPU core" without causing problems.<br> <p> <span class="QuotedText">&gt; The main exception is SeqCst fences after SeqCst RMW operation. Those are unnecessary and pretty expensive (a few tens of cycles) even on x86, and we have a couple in really hot places. I think only Arm needs a processor fence instead, for some unobvious reason related to the semantics of LDAR instructions (which are stronger than just acquire) and to the code that's generated for SeqCst RMW operations.</span><br> <p> If those fences can always be compiled to NOPs (presumably with some restriction on what happens between the RMW and the fence), that *sounds* like something that the codegen backend of a compiler should take care of. Backends can do optimizations that programmers cannot do if those optimizations are done sufficiently late during compilation that the program can already be considered to run with a lower-level memory model.<br> </div> Sat, 17 Aug 2024 10:14:41 +0000 Java/C# vs Rust https://lwn.net/Articles/986076/ https://lwn.net/Articles/986076/ khim <font class="QuotedText">&gt; They don't have to do monomorphisation that requires you to keep pretty much all the stuff in RAM.</font> <p>Which means that it would have been Rust with <a href="https://en.wikipedia.org/wiki/Pascal_(programming_language)#ISO/IEC_10206:1990_Extended_Pascal">Extended Pascal</a>/<a href="https://en.wikipedia.org/wiki/Ada_(programming_language)#Generics">Ada</a> like generics (which would have evolved into a <a href="https://faultlore.com/blah/swift-abi/">Swift-like generics</a> later, most likely).</p> <p>I think we are arguing about different things: you say that Rust in a form <b>exactly like Rust was done in 2015</b> wasn't possible to gave in year 1995 while I say that Rust with <b>all the important properties that matter for safety</b> was easy to create using 1995 technology.</p> <p>It wouldn't have been competitive with what we have today but it would have been as fast as Java in 1995 (Java wasn't a speed daemon back then buy any means) <b>and</b> it could have evolved, over time, into safe language that could be used for low-level things like Linux kernel, too.</p> <p>But Java had better marketing <b>and</b> it also promoted write once, run anywhere myth thus it was chosen. And we had to wait 20 years for a something that's safer than <a href="https://en.wikipedia.org/wiki/Intel_iAPX_432">what we had in a year 1981</a>.</p> Sat, 17 Aug 2024 04:13:37 +0000 Java/C# vs Rust https://lwn.net/Articles/986075/ https://lwn.net/Articles/986075/ Cyberax <div class="FormattedComment"> <span class="QuotedText">&gt; I don't think it was lack of resources. From Visual Studio blog: throughout the VS 2015 cycle we’ve been focusing on the quality of our expression SFINAE implementation. That's year 2016!</span><br> <p> gcc was not much better. It did not support member templates until 2.95 in 1999. In 1995 it did not even support type deduction properly, instead relying on "guiding declarations": <a href="https://support.sas.com/documentation/onlinedoc/ccompiler/doc700/html/cpp/z0179750.htm">https://support.sas.com/documentation/onlinedoc/ccompiler...</a> - you had to explicitly match types, as the compiler couldn't deduce the common types.<br> <p> <span class="QuotedText">&gt; Um. That's how Turbo Pascal 4+ did starting from year 1987 and how Ada did from the day one in year 1983. </span><br> <p> They don't have to do monomorphisation that requires you to keep pretty much all the stuff in RAM. <br> </div> Sat, 17 Aug 2024 03:45:31 +0000 Java/C# vs Rust https://lwn.net/Articles/986073/ https://lwn.net/Articles/986073/ khim <font class="QuotedText">&gt; The abovementioned Watcom C/C++ did not support template members, SFINAE, and even ":" initializers in constructors.</font> <p>I don't think it was lack of resources. From Visual Studio blog: <a href="https://devblogs.microsoft.com/cppblog/sfinae-update/">throughout the VS 2015 cycle we’ve been focusing on the quality of our expression SFINAE implementation</a>. That's year 2016!</p> <p>It's just hard to support certain things when your compiler is not designed to support them. But the fact is that in year 1995 there already <b>were</b> compilers that supported pretty advanced C++ (I think Borland was the most advanced at that time, still) means Rust could have existed back then if someone would have invented it.</p> <font class="QuotedText">&gt; Rust can't compile individual files like C or C++ compilers (of that time). It can operate at most on the crate level.</font> <p>Um. That's how Turbo Pascal 4+ did starting from year 1987 and how Ada did from the day one in year 1983. Not a rocket science at all and, in fact, it <b>reduces</b> resources consumption not increases them: no need to parse the same thing again and again and again.</p> Sat, 17 Aug 2024 03:31:24 +0000 Java/C# vs Rust https://lwn.net/Articles/986072/ https://lwn.net/Articles/986072/ Cyberax <div class="FormattedComment"> Rust can't compile individual files like C or C++ compilers (of that time). It can operate at most on the crate level.<br> <p> <span class="QuotedText">&gt; Sure, if Rust would have arrived in year 1995 then it would have been as slow as C++ with heavy template libraries was back then and then Linus would have rejected it, but I don't see what could have prevented Rust from improving in similar fashion to how C++ improved over time.</span><br> <p> Heavy template libraries really started appearing in 2000-s, when RAM and CPUs became available. In 90-s a lot of compilers struggled with the STL. The abovementioned Watcom C/C++ did not support template members, SFINAE, and even ":" initializers in constructors.<br> </div> Sat, 17 Aug 2024 02:32:14 +0000 Java/C# vs Rust https://lwn.net/Articles/986071/ https://lwn.net/Articles/986071/ khim <font class="QuotedText">&gt; Rust wouldn't have been possible in 1995, simply because the compilation times and memory requirements were impossibly high for the computers of that period.</font> <p>What exactly makes Rust extra-heavy? In my experience Rust compiler have similar memory consumption and similar compilation times to C++ compiler and C++ wasn't even all that new in 1995, Borland C++ 4.5, Visual C++ 4.0, Watcom C++ 10.5 were already released in year 1995. All of them included pretty sophisticated and non-trivial template libraries and other pretty heavy things (<code>windows.h</code> alone was humongous, even back then).</p> <p>Sure, if Rust would have arrived in year 1995 then it would have been as slow as C++ with heavy template libraries was back then and then Linus would have rejected it, but I don't see what could have prevented Rust from improving in similar fashion to how C++ improved over time.</p> Sat, 17 Aug 2024 02:19:35 +0000 Banning unsafe in Rust for Linux device drivers https://lwn.net/Articles/986063/ https://lwn.net/Articles/986063/ Wol <div class="FormattedComment"> I don't really make much use of its power at work, but aiui, Slack allows edits for a *short* time.<br> <p> So you might have a bit of a pain with moderation, but if you only allowed editing within, say, five minutes of the original post, then it balances your need to moderate with a poster's desire to correct something. After all, I expect most people spot their mistakes as they click "post" :-)<br> <p> Cheers,<br> Wol<br> </div> Fri, 16 Aug 2024 23:10:53 +0000 Banning unsafe in Rust for Linux device drivers https://lwn.net/Articles/986056/ https://lwn.net/Articles/986056/ rc00 <div class="FormattedComment"> <span class="QuotedText">&gt; Can you delete history on github?</span><br> <p> Yes.<br> </div> Fri, 16 Aug 2024 22:07:46 +0000 Java/C# vs Rust https://lwn.net/Articles/986049/ https://lwn.net/Articles/986049/ Cyberax <div class="FormattedComment"> <span class="QuotedText">&gt; Would it have been better if Rust had been available in 1995?</span><br> <p> Rust wouldn't have been possible in 1995, simply because the compilation times and memory requirements were impossibly high for the computers of that period. <br> <p> Golang would have worked, though.<br> </div> Fri, 16 Aug 2024 21:29:51 +0000