|
|
Log in / Subscribe / Register

Rust support hits linux-next

Rust support hits linux-next

Posted Mar 21, 2021 21:42 UTC (Sun) by moltonel (subscriber, #45207)
In reply to: Rust support hits linux-next by adobriyan
Parent article: Rust support hits linux-next

> C++ is maximally source compatible with C which automatically makes it the best candidate for upgrading to a more capable programming language.

This is debatable. Some very smart and knowledgeable Linux devs still give C++ a firm "No", while they're giving Rust a cautious "Maybe". You shouldn't ignore that hint.

Any tech shift needs a high gain-over-cost ratio. While the cost of enabling C++ build in a C project is indeed very low, the gains are (in Linux's case, and compared to Rust) not amazing either, and the inadvertent compatibility issues can negate a lot of the gains. Which leads to another counter-argument: being source-incompatible might actually be a good thing, as the clear demarcation between the C world and the Rust world could be more manageable than the fuzzy C/C++ demarcation.

The jury is still out on Linux-Rust, but Linux-C++ looks like a well-beaten dead horse.


to post comments

Rust support hits linux-next

Posted Mar 22, 2021 11:10 UTC (Mon) by Wol (subscriber, #4433) [Link] (3 responses)

> This is debatable. Some very smart and knowledgeable Linux devs still give C++ a firm "No", while they're giving Rust a cautious "Maybe". You shouldn't ignore that hint.

We've had that discussion elsewhere. Linux needs a low-level language, and probably the best definition of such a language is "it doesn't give the optimiser many options". The linux devs don't like getting bitten by optimisations where the compiler "assumes facts not in evidence", and C++ adds far too many features that enable exactly that.

I gather Rust has been designed as a low-level language, and as such is currently much better than C, which has steadily been acreting hi-level features. That's not to say it'll *stay* a low-level language, but at present Rust is actually probably a far better language than C for system-level programming.

Cheers,
Wol

Rust support hits linux-next

Posted Apr 27, 2021 14:25 UTC (Tue) by nix (subscriber, #2304) [Link] (2 responses)

> I gather Rust has been designed as a low-level language, and as such is currently much better than C, which has steadily been acreting hi-level features.

That's a fairly ridiculous characterization. By any standard, Rust is much higher-level than C: you name it, language-wise it has way more advanced features and permits a higher level of abstraction than C does. What it also has is more consistency (fewer implementation-defined edge cases).

Rust support hits linux-next

Posted Apr 27, 2021 16:21 UTC (Tue) by Wol (subscriber, #4433) [Link] (1 responses)

But does it also provide more control over the machine code that's generated?

I've come to the conclusion that a good low-level language "does not give the compiler much opportunity to optimise well-written code". It seems most problems with C (for the kernel at least) are caused by the compiler optimising the hell out of it.

So long as high-level constructs map cleanly to the obvious underlying machine/assembler code, I'd call that a "good low-level language".

Cheers,
Wol

Rust support hits linux-next

Posted Apr 27, 2021 17:01 UTC (Tue) by mathstuf (subscriber, #69389) [Link]

Depends on who you ask I guess. Is it "clear" when a chain of iterator calls are fused into a single loop over the input? Is it "clear" when tail call optimization is applied? I couldn't tell you what instructions any given line compile down to in Rust or C myself anyways, so for me none of it is "clear" anyways.

That said, I don't know Rust's guarantees around reordering statements, but given the more explicit "I'm using a single variable across threads" model, there are likely a lot fewer ways the compiler can think to order things (barring bugs in the compiler, but that's C's problem too).


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds