Cancer?
Cancer?
Posted Feb 16, 2025 19:05 UTC (Sun) by smurf (subscriber, #17840)In reply to: Cancer? by LtWorf
Parent article: Resistance to Rust abstractions for DMA mapping
Arguably it's not.
It just looks easier. C definitely has fewer syntax rules and fewer restrictions than Rust.
The problem is that those rules and restrictions *do* exist in (kernel) C, it's just that the compiler doesn't help enforce them, let alone emit helpful (no scare quotes – Rust is reasonably good in that regard) error messages.
Instead you get to learn the rules by experience and/or reading the sources of whatever code you call, code review that hopefully finds some of the more egregious problems, debugging crashed kernels, followup patches that fix your mistakes, and so on.
Speaking of code review. There's only so much mental bandwidth. Making sure that the code in question obeys the locking rules du jour, doesn't have use-after-free problems, and so on, means less focus on the actual logic.
Posted Feb 17, 2025 6:09 UTC (Mon)
by LtWorf (subscriber, #124958)
[Link] (2 responses)
The awkward moment when you reply before reading what you're replying to, and you miss the line: "As for rust in general, there's a number of reason to still be using C now:".
You're basically arguing that python is harder because it has more hidden gotchas.
Is assembly easy since it's completely explicit then? Should we be using assembly directly? Should you have read my comment before replying to it?
(for me it's no, no, yes)
Posted Feb 17, 2025 7:38 UTC (Mon)
by smurf (subscriber, #17840)
[Link] (1 responses)
For the record, I didn't miss that line at all. I merely disagree, rather vehemently in fact, with your "C is easier" point. Because it definitely isn't. Not by the time you need to use nontrivial interfaces … like the rest of the Linux kernel, which I assume is still the context of this discussion.
C (and even more so, assembly) is not at all explicit in the sense that the interfaces to existing code are full of implied assumptions you need to adhere to, otherwise your code is buggy and will crash on you (or randomly corrupt your users' RAM, who knows). By contrast, in well-written Rust interfaces most of those cannot-be-stated-in-C-much-less-assembler assumptions are right there and the *compiler* will *tell* you if you violate them.
Posted Feb 17, 2025 8:12 UTC (Mon)
by LtWorf (subscriber, #124958)
[Link]
You keep talking about kernel and it was referred to user space. Since I even spoke about distributing and dependencies, which are very different on the kernel… That's because the comment I was replying to was wondering why would anyone still use C in general.
Cancer?
Cancer?
Cancer?