Re:Effective Rust
by Firadeoclus on Thursday June 15, 2023 @01:14PM
(#36343670)
This. Being able to expand macros lets you learn what it does in context, and once you're more familiar with the abstraction it gives you the benefit of hiding the details and highlighting the moving parts within an otherwise static structure.
>But maybe this is a tooling problem? What if we could see the code in a simpler way even if the actual code involves macros and templates?
Intelllij Rust plugin does this.
println!("Hello, world! {}", x);
>Recursive expansion of println! macro:
>{
> ::std::io::_print(IntellijRustDollarCrate::format_args_nl!("Hello, world! {}", x));
>}
But I think the main problem here is the famous debate of statically-typed languages vs dynamic ones. As statically-typed languages add more and more features to be more expressive, they have to work around the compiler limitations and create very bizarre syntaxes if they want to keep performance.
But maybe this is a tooling problem? What if we could see the code in a simpler way even if the actual code involves macros and templates?
Swift has just implemented macros that Xcode expand to show the generated code in a collapse/expand way, making it easy to understand what it does.