r/programming • • Aug 29 '24

One Of The Rust Linux Kernel Maintainers Steps Down - Cites "Nontechnical Nonsense"

https://www.phoronix.com/news/Rust-Linux-Maintainer-Step-Down
1.2k Upvotes

795 comments sorted by

View all comments

Show parent comments

2

u/Kraigius Aug 30 '24 edited Dec 10 '24

ghost mountainous judicious fretful meeting middle quiet growth toothbrush weather

This post was mass deleted and anonymized with Redact

20

u/tsimionescu Aug 30 '24

There is a major difference between a function returning void*, which is a pointer to literally anything, and a function returning Either<Aref<This>, Aref<That>>. It's not just syntax: with a void* function, you can modify to return something else than what it does today, and not break any other code, as long as you also modify the place that ultimately uses that value (all the code between your function and the ultimate destination stays unchanged). Or, you can add a new return type in a new case and really not break anything at all.

When you start adding more specific types, this goes out the window. If the function now returns an Either<Aref<This>, Aref<Something>>, you have to propagate this type signature change through all layers of code. If you want to start returning a third possibility as well, again all places that worked with it need to change.

Of course, this has upsides and downsides. In the C model, the compiler won't tell you that you forgot to change some places and now those functions fail because they were expecting the void* to point to a That but now it points to a Something. And if the Something has more complex semantics and now needs, say, special cleanup logic to work properly, then your code can be more subtly wrong, and C won't help you figure it out, while the Rust approach would probably even handle that automatically.

9

u/[deleted] Aug 30 '24

While obviously anything else than void * would sound like a requirement for a kernel, there should be a concern that an overly verbose type system will quickly tie you up in a knot, as one tiny change will have to trickle all the way through anywhere that type is used.

I don't see a challenge for a C developer having to fix problems they introduced, even if that bleeded in to the Rust side. What the C programmer dislikes is that the ability to cheat is removed.

You can work around that by having a flexible set of base interface/types like Filesystem or Device, which again you would think a kernel source code would have.

6

u/FlakyLogic Aug 30 '24 edited Aug 31 '24

Or, you can add a new return type in a new case and really not break anything at all. 

I think that Rust has a way to allow that with traits, but it's probably even more frightening to programmers unfamiliar with Rust than the type given in the talk. 

5

u/Kraigius Aug 30 '24 edited Dec 10 '24

workable nutty swim beneficial bright muddle like simplistic elastic attempt

This post was mass deleted and anonymized with Redact

6

u/tsimionescu Aug 30 '24

Yes, void* is similar to those things. Keep in mind that in C there is no other way to do polymorphism, though, there is no equivalent to an interface type.

4

u/tejp Aug 30 '24

I just can't grasp what "encoding huge amounts of semantics into the type system" means to him

In the C API you have a type struct inode (or something) and you have a function that for example allocates such a struct and one that sets up reference counting for such an allocated struct and one that does some special initialization in the struct. All the functions just operate on struct inode.

The "encode semantics into the type system" means, in this case, you add different types for the different states. So the allocation function returns a InodeMem and the function that sets up the reference counting takes such a InodeMem and returns a InodeRefCounted and the initialization function takes a InodeRefCounted and returns a InodeInited.

An advantage is that you can't by accident give a InodeMem to a function that expected an InodeInited, a disadvantage is that a change in the semantics of the code at one point might cause far reaching changes to the types of many functions all over the place.

4

u/el_muchacho Aug 30 '24 edited Aug 30 '24

I just can't grasp what "encoding huge amounts of semantics into the type system" means to him

Basically, if you watch the video, the Rust API is completely different from the C API it tries to replicate. So it's not just a matter of having a different language coding the same API, it's two completely different very complex code bases written by different teams in different languags that are supposed to do the exact same thing. So it's understandable that he doesn't want to have to understand, maintain and validate another code base.

This sort of work exists in aeronautics, where the same API is written by two separate teams, often in two different languages, for the sake of redundancy. But when a member of the team A corrects a bug, he is not supposed to correct it in the B code base as well. Also, for development, the two teams have to coordinate and agree on a single API, not two different APIs.

And no, it's wrong to say it doesn't affect them. If a makes a wrong fix in the Rust code base, he would be responsible, and he doesn't want to take that responsibility.