News for hackers. Stuff that matters.
Re:Resigning as Asahi Linux project lead by Certhas on Thursday February 13, 2025 @11:42AM (#43037926)
It's also not truthful because many of the Rust maintainers are long time C contributors.

Marcan also linked to this resignation of a Rust Maintainer:

https://lore.kernel.org/lkml/20240828211117.9422-1-wedsonaf@...

which references this fantastic exchange:

https://www.youtube.com/watch?v=WiPp9YEBV0Q&t=1529s

I am not a C person, or a kernel level person, I just watch this from the sideline to learn something every now and then (and for the drama). But this exchange is really stunning to me. It seems so blatantly obvious to me that systematically documenting (in code!) and automatically checking semantic information that is required to correctly use an API is a massive win. But I have encountered this type of resistance (by very smart developers building large systems) in my own much smaller and more trivial context. To some degree, the approach seems to be: "If I never write down what I mean precisely, I won't have to explain why I changed things." A more charitable reading of the resistance is: Adding a new place where the semantics are written down (code, documentation and now type system) gives one more way in which they can be out of sync or subtly inconsistent or overly restrictive.

But yeah, my intuitive reaction to the snippet above is just incredulity at the extreme resistance to precisely encoding your assumptions.

Re:Resigning as Asahi Linux project lead by mietek on Thursday February 13, 2025 @11:55AM (#43038134)
Your charitable reading is too charitable. One of the benefits of using types to help guarantee properties of programs (e.g. invariants) is that types do not get out of sync with the code, because they are part of the code, unlike documentation. The language implementation (e.g. the compiler) automatically checks that the types continue to match the rest of the code, in order to catch problems as early as possible.
Re:Resigning as Asahi Linux project lead by diggan on Thursday February 13, 2025 @12:04PM (#43038265)
I'm not a kernel developer, and never done anything of the sorts either. But, I think the argument is that if they have two versions of something (the C version + the Rust bindings), the logic/behavior/"semantics" of the C version would need to be encoded into the Rust types, and if a C-only developer changes the C version only, how are they supposed to proceed with updating the Rust bindings if they don't want to write Rust?

At least that's my understanding from the outside, someone please do correct me if wrong.

Re:Resigning as Asahi Linux project lead by ChocolateGod on Thursday February 13, 2025 @12:16PM (#43038440)
[delayed]
Re:Resigning as Asahi Linux project lead by bcrosby95 on Thursday February 13, 2025 @12:14PM (#43038408)
That was a large part of the disagreement.

Rust developers were saying it would be their job to do this. But then someone said Linus rejected something because it broke Rust. GKH backed the Rust developers and said that was an exception not a rule, but didn't know Linus' stance for sure.

Then Linus chimes in because of one of Hector's replies, but at the time of my reading did not clarify what his actual stance is here.

Re:Resigning as Asahi Linux project lead by ChocolateGod on Thursday February 13, 2025 @12:17PM (#43038452)
> but at the time of my reading did not clarify what his actual stance is here.

Whatever he says is guaranteed to piss off at least one side of the argument.

Re:Resigning as Asahi Linux project lead by dralley on Thursday February 13, 2025 @03:15PM (#43040728)
You still have to make the stance clear. Avoiding conflicts and dealing with them are two different things.
Re:Resigning as Asahi Linux project lead by rekoil on Thursday February 13, 2025 @12:58PM (#43039027)
Yeah it's not an easy discussion for sure, but he has to say something.

At the rate we're going here the existing kernel devs will alienate any capable new blood, and Linux will eventually become Google Linux(TM) as the old guard goes into retirement and the only possible way forward is through money.

Re:Resigning as Asahi Linux project lead by procaryote on Thursday February 13, 2025 @02:18PM (#43040050)
Doesn't that assume all "capable new blood" is enthusiastic about rust in the kernel? It seems like a pretty big assumption
Re:Resigning as Asahi Linux project lead by rekoil on Thursday February 13, 2025 @02:56PM (#43040513)
You’re not wrong (in that I was insinuating something like that), but I’ll point out it’s an almost equally big assumption that we’re somehow going to find a trove of capable developers interested in devoting their careers to coding in ancient versions of C.
Re:Resigning as Asahi Linux project lead by lukaslalinsky on Friday February 14, 2025 @01:13AM (#43045403)
Do you really think there are no young people wanting to work on an operating system written in C? I'm very skeptical that all young people interested in operating systems see Rust as the future. I personally feel it's the other way around, it's Google and companies like that who really want Rust in Linux, the young kernel devs are a minority.
Re:Resigning as Asahi Linux project lead by veidr on Friday February 14, 2025 @05:59AM (#43047139)
It's not that people think that there are no young people wanting to work in C, it's that the number of competent programmers who want to use C, or do use C, are both decreasing every year. That has been the trend for quite a while now.

So there will presumably be fewer and fewer programmers, young or old, that want to work in C.

C is one of the most entrenched and still-important languages in the world, so it probably has more staying power than Fortran, COBOL, etc. So the timeline is anybody's guess, but the trajectory is pretty clear.

There are a lot of languages that people prefer to C which aren't well-suited to OS programming (golang, Java) but Rust is one that can do the same job as C, and is increasingly popular, and famously well-loved by its users.

There's no guarantee that Rust will work out for Linux. Looks unlikely, to me, actually. But I think it's pretty clear that Linux will face a dwindling talent pool if the nebulous powers that actually control it collectively reject everything that is not C.

Re:Resigning as Asahi Linux project lead by ChocolateGod on Friday February 14, 2025 @11:25AM (#43050048)
Let's add Swift support to Linux :)
Re:Resigning as Asahi Linux project lead by rekoil on Thursday February 13, 2025 @12:25PM (#43038560)
Which is a moot point because the agreement right now is that Rust code is allowed to break, so the C developer in question can just ignore Rust, and a Rust person will take care of it for them.
Re:Resigning as Asahi Linux project lead by rc00 on Thursday February 13, 2025 @01:30PM (#43039430)
As of today, the burden is uncertain and the Rust crowd has not been fixing things quickly enough since they are manual fixes:

https://lore.kernel.org/rust-for-linux/20250131135421.GO5556...

> Then I think we need a clear statement from Linus how he will be working. If he is build testing rust or not.

> Without that I don't think the Rust team should be saying "any changes on the C side rests entirely on the Rust side's shoulders".

> It is clearly not the process if Linus is build testing rust and rejecting PRs that fail to build.

For clarity, tree-wide fixes for C in the kernel are automated via Coccinelle. Coccinelle for Rust is constantly unstable and broken which is why manual fixes are required. Does this help to explain the burden that C developers are facing because of Rust and how it is in addition to their existing workloads?

Re:Resigning as Asahi Linux project lead by rekoil on Thursday February 13, 2025 @02:03PM (#43039842)
> Does this help to explain the burden that C developers are facing because of Rust and how it is in addition to their existing workloads?

Yep, thanks!

Re:Resigning as Asahi Linux project lead by diggan on Thursday February 13, 2025 @12:32PM (#43038682)
> Which is a moot point because the agreement right now is that Rust code is allowed to break, so the C developer in question can just ignore Rust

So then the argument that even semantics encoded in the Rust types, can be out of the date compared to the actual code, is actually a real thing? I read that somewhere else here in the comments, but didn't understand how the types could ever be out-of-date, but this would explain that argument.

Re:Resigning as Asahi Linux project lead by rowanG077 on Thursday February 13, 2025 @12:58PM (#43039030)
That's exactly what would happen "types get out of date". I'm not sure what you are familiar with. But imagine in python a new version of a library is released that now has an extra required argument on a function.
Re:Resigning as Asahi Linux project lead by rekoil on Thursday February 13, 2025 @12:53PM (#43038955)
As I understand it everything Rust is seen as "optional", so a CONFIG_RUST=n build that succeeds means a-OK, then some Rust person will do a CONFIG_RUST=y build, see it's broken, fix it, and submit a patch.

I may be wrong, but that's how I understood it, but who knows how Linus will handle any given situation. ¯\_(ツ)_/¯

Re:Resigning as Asahi Linux project lead by Certhas on Thursday February 13, 2025 @12:49PM (#43038906)
Yes, but generic code complicates the picture. The things I saw were like: The documentation says you need a number but actually all you need is for the + operator to be defined. So if your interface only accepts numbers it is unnecessarily restrictive.

Conversely some codepath might use * but that is not in the interface, so your generic code works for numbers but fails for other types that should work.

Re:Resigning as Asahi Linux project lead by s1mplicissimus on Thursday February 13, 2025 @02:03PM (#43039834)
> Yes, but generic code complicates the picture. The things I saw were like: The documentation says you need a number but actually all you need is for the + operator to be defined. So if your interface only accepts numbers it is unnecessarily restrictive.

if you really need a number, why not use a type specifically aligned to that (something like f32|f64|i32|i64 etc...) instead of relying on + operator definition?

> Conversely some codepath might use * but that is not in the interface, so your generic code works for numbers but fails for other types that should work.

do we agree that if it's not in the interface you are not supposed to use it? conversely if you want to use it, the interface has to be extended?

Re:Resigning as Asahi Linux project lead by Certhas on Thursday February 13, 2025 @02:12PM (#43039966)
Yes, the second case is a bug in the interface.

For the first case you have it the wrong way around. My generic code would work on things that are not numbers but I prevent you from calling it because I didn't anticipate that there would be things you can add that are not numbers. (Better example: require an array when you really only need an iterable).

Re:Resigning as Asahi Linux project lead by jstimpfle on Thursday February 13, 2025 @12:03PM (#43038259)
It's practically impossible to document all your assumptions in the type system. Attempting to do so results in code that is harder to read and write.

You have a choice between code that statically asserts all assumptions in the type system but doesn't exist, is slow, or a pain to work with, and code that is beautiful, obvious, performant, but does contain the occasional bug.

I am not against static safety, but there are trade offs. And types are often not the best way to achieve static safety.

Re:Resigning as Asahi Linux project lead by K0nserv on Thursday February 13, 2025 @12:32PM (#43038681)
Encoding assumptions and invariants in the type system is a spectrum. Rust, by it's very nature, places you quite far along that spectrum immediately. One should consider if the correctness achieved by this is worth the extra work. However, if there is one place where correctness is paramount, surely it's the Linux Kernel.

> [..]Attempting to do so results in code that is harder to read and write.

> You have a choice between code that statically asserts all assumptions in the type system but doesn't exist, is slow, or a pain to work with, and code that is beautiful, obvious, performant, but does contain the occasional bug.

I don't think you are expressing objective truth, this is all rather subjective. I find code that encodes many assumptions in the type system beautiful and obvious. In part this is due to familiarity, of course something like this will seem inscrutable to someone who doesn't know Rust, in the same way that C looks inscrutable to someone who doesn't know any programming.

Re:Resigning as Asahi Linux project lead by purplesyringa on Thursday February 13, 2025 @01:02PM (#43039083)
> Encoding assumptions and invariants in the type system is a spectrum. Rust, by it's very nature, places you quite far along that spectrum immediately.

Compared to, say, dependent type systems, Rust really isn't that far along. The Linux kernel has lots of static analyzers, and then auxiliary typedefs, Sparse, and sanitizers cover a significant area of checks in an ad-hoc way. All Rust does is formalize them and bring them together.

And getting Rust into the kernel slowly, subsystem by subsystem, means that the formalization process doesn't have to be disruptive and all-or-nothing.

Re:Resigning as Asahi Linux project lead by Certhas on Thursday February 13, 2025 @12:42PM (#43038818)
But if the info is info the user of your code needs in order to interface correctly, the point that you can't document everything is moot. You already have to document this in the documentation anyways.
Re:Resigning as Asahi Linux project lead by josephg on Thursday February 13, 2025 @12:44PM (#43038848)
> And types are often not the best way to achieve static safety.

That’s a sort of weird statement to make without reference to any particular programming language. Types are an amazing way to achieve static safety.

The question of how much safety you can reasonably achieve using types varies wildly between languages. C’s types are pretty useless for lots of reasons - like the fact that all C pointers are nullable. But moving from C to C++ to Rust to Haskell to ADA gives you ever more compile time expressivity. That type expressivity directly translates into reduced bug density. I’ve been writing rust for years, and I’m still blown away by how often my code works correctly the first time I run it. Yesterday the typescript compiler (technically esbuild) caught an infinite loop in my code at compile time. Wow!

I’d agree that every language has a sweet spot. Most languages let you do backflips in your code to get a little more control at compile time at the expense of readability. For example, C has an endless list of obscure __compiler_directives that do all sorts of things. Rust has types like NonZeroUsize - which seem like a good idea until you try it out. It’s a good idea, but the ergonomics are horrible.

But types can - and will - take you incredibly far. Structs are a large part of what separates C from assembler. And types are what separates rust from C. Like sum types. Just amazing.

Re:Resigning as Asahi Linux project lead by Ar-Curunir on Thursday February 13, 2025 @01:03PM (#43039093)
The particular C maintainers in discussion refused to provide even textual documentation.