A lot of good stuff in there
A lot of good stuff in there
Posted Feb 16, 2025 10:38 UTC (Sun) by adobriyan (subscriber, #30858)In reply to: A lot of good stuff in there by dralley
Parent article: New leadership for Asahi Linux
Had they make main() to be main(arg0: &[u8], arg: &[&[u8]]) or equivalent it should have been more obvious what to do.
Posted Feb 16, 2025 14:19 UTC (Sun)
by khim (subscriber, #9252)
[Link]
Sure, but why would they do something that doesn't work correctly? On POSIX there are no guarantee that In essence that's an example of what Rust does: instead of “easy” it usually picks “correct”.
Posted Feb 16, 2025 14:29 UTC (Sun)
by intelfx (subscriber, #130118)
[Link]
Yes. "For every complex problem, there's a solution that is simple, neat, and wrong."
argv is a pointer to global, mutable data. Attempting to represent it as a Rust reference is completely incorrect with respect to Rust aliasing semantics. The Rust standard library goes to some contortions to wrap argc/argv into a memory-safe abstraction, and an iterator is more-or-less the best way one can do it. Google "rust why args is an iterator" for details.
Posted Feb 16, 2025 14:52 UTC (Sun)
by intelfx (subscriber, #130118)
[Link]
Indeed, if Rust is worthless, then you can just compare it piece-by-piece to C and every idiom where C is "easier" than Rust means that C is the "winner," because Rust has no added value (by postulate) and therefore the "easier" thing wins.
However, this is a fallacy. If Rust had been just a clone of C with a worse syntax, then it would indeed be worthless, but that's not the case. Rust is valuable precisely because it is *not* a clone of C with a worse syntax. It is a different language, built on different concepts and abstractions, chosen for their *value*, and those concepts and abstractions necessitate different idioms to realize that value.
> Had they make A lot of good stuff in there
main() to be main(arg0: &[u8], arg: &[&[u8]]) or equivalent it should have been more obvious what to do
arg0 exists and Windows program doesn't even receive the list of command-line arguments, but one, single, array of USC-2 characters (no, not UTF-16 as people often think)!A lot of good stuff in there
A lot of good stuff in there
