|
|
Subscribe / Log in / New account

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

In some sense this specific problem is Rust problem -- doubling down on Iterators at main() time.

Had they make main() to be main(arg0: &[u8], arg: &[&[u8]]) or equivalent it should have been more obvious what to do.


to post comments

A lot of good stuff in there

Posted Feb 16, 2025 14:19 UTC (Sun) by khim (subscriber, #9252) [Link]

> Had they make main() to be main(arg0: &[u8], arg: &[&[u8]]) or equivalent it should have been more obvious what to do

Sure, but why would they do something that doesn't work correctly? On POSIX there are no guarantee that 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)!

In essence that's an example of what Rust does: instead of “easy” it usually picks “correct”.

A lot of good stuff in there

Posted Feb 16, 2025 14:29 UTC (Sun) by intelfx (subscriber, #130118) [Link]

> Had they make main() to be main(arg0: &[u8], arg: &[&[u8]]) or equivalent it should have been more obvious what to do.

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.

A lot of good stuff in there

Posted Feb 16, 2025 14:52 UTC (Sun) by intelfx (subscriber, #130118) [Link]

The cynic in me wants to say that all of this confusion stems precisely from this fallacious premeditated state of mind that "Rust is worthless." In other words, you are going from the answer to the question. You have this premeditated answer that "Rust is worthless," and you try to imagine the rest of the world that would fit the answer.

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.


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