> but inline assembly in C relies on vendor-specific extensions.
Whereas Rust is a standard with multiple implementations?
Re:Was Rust Worth It?
by oconnor663 on Wednesday October 25, 2023 @09:38PM
(#38020688)
I should've said "stabilized" instead of "standardized" to avoid stepping on this conversational landmine. But an important practical difference is that Rust supports inline assembly on Windows. (Correct me if I'm wrong, but I think MSVC mostly does not support inline asm.)
It does support inline assembly [1]. However, it's different than the way GCC supports inline assembly. It seems nicer, TBH.
[1]: https://learn.microsoft.com/en-us/cpp/assembler/inline/inlin...
Re:Was Rust Worth It?
by oconnor663 on Wednesday October 25, 2023 @10:21PM
(#38020942)
From that source:
> Inline assembly is not supported on the ARM and x64 processors.
Oh, my bad. I should have read the source more closely. I hadn't realized only 32-bit x86 processors were supported.
That's hilarious. Like, the compiler team had ONE GUY that believed in and developed this feature and retired in 1999.
I can't remember where I heard this, so take it with a grain of salt.
IIRC, the MSVC C/C++ compilers don't output assembly and then assemble that with an assembler; they output machine code directly for efficiency. It could be that inline assembly would require an assembly language parser that would have to be merged into the compiler and complicate the architecture, and they have no reason to do that unless enough paying customers request it.
But to your point, the _defaults_ are very different. Things like raw pointer casts require a lot of ceremony and careful thought in Rust, and they have to follow more rules than in C. In particular, Rust references are all effectively "restrict", and it's really easy to screw that up when you do unsafe cast from raw pointers to safe references, which is a big incentive not to write code that needs to do that if you have a choice.