by fauigerzigerk · 7y ago · 0 comments
I don't think it makes sense to compare the output of Rust macros to assembly code generated by a C compiler or to vtables.
Macros are part of the Rust language, as is their output. Understanding Rust means understanding both input and output. So this abstraction boundary is intentionally leaky to some degree.
Generated assembly and vtables on the other hand are compiler implementation details subject to change without notice. Any abstraction leakage is unintended and undesirable (even if developers sometimes benefit from understanding that output)
Your line of reasoning makes all debates about language complexity completely pointless.
For example, no need to understand the magic behind the 'quote!' or the #[async_trait] macros to use them.
As a consequence, criticising the complexity of whatever a C compiler generates cannot possibly be valid criticism of C's complexity on a _semantic_ level whereas criticising the output of a Rust macro can be valid criticism of Rust on a semantic level.
Most C programmers won't have to write or understand inline assembly often, if ever. Of course you can encounter it in production problem or something, so you could make an argument that all C programmers need to understand "C with inline assembly", which you are making for Rust macros.
As long as you just use Rust macro's and not write your own you are solidly in "C without inline assembly" territory.
I couldn't disagree more. Macros are not similar to inline assembly at all precisely because they do _not_ step outside the bounds of the language.
Whatever similarities you may find, it's simply not helpful to deny the fundamental distinction between language A generating code in language A and language A invoking/generating code in language B.
It's futile to debate the properties of a particular language if you can't make a distinction between that language and anything it can generate or embed in some opaque way.