this post was submitted on 19 Jan 2026
0 points (50.0% liked)
Rust
7684 readers
25 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I see what you mean. OK, I haven't read the rust language specs, RFCs or whatever, so this is my guess why it was done that way.
Regarding derive: Rust doesn't have inheritance but it does have traits / interfaces. This is both an advantage and a disadvantage. For environment with constrained resources, having structs that dont implement a bunch of things you don't need is an advantage. The downside is that in other cases, you need to know what you want.
For example not every class needs to be comparable or know how to print itself to debug output. But if you do want that, you need to know to implement the right trait. Implementing the same trait the same way all the time however is just boilerplate, hence, the derive macro.
At the same time proc-macros like derive ate extremely powerful since they ingest the syntax tree and spit one back out. It allows you to do crazy stuff at compile time with all the IDE goodness of showing docs, finding symbols, and type checking. IDEs can predictably expand macros. I have yet to find an IDE besides CLion that does the same with C/C++ code.
Process macros in rust can do things like consume files (statically as in inserted by the compiler as opposed to dynamically I'm the function browsing the filesystem), which allows reading and interpreting another language, like python or perl, to generate symbols for those other languages. It is thus possible for example to write a python module completely in Rust. With work, it theoretically is possible to also extend python classes (or symbols from other languages) purely in rust.
As for println! and format!, those macros are in the STL. They don't make it heavier. I think they are macros because rust doesn't (or didn't) support variadic arguments.