Declarative macros (specifically, macro_rules!
) are used in FRAME V1. Most of FRAME pallets written prior to January 2021 use these. FRAME V2 on the other hand, officially introduced in January 2021 uses attribute macros and today are what all FRAME pallets use. There still exists projects which use FRAME V1 however developers are encouraged to upgrade their pallets. Although V2 is backwards compatible with V1, V1 is no longer being improved for new features.
The major improvements from V1 and V2 is that V2 provides a much better developer experience.
Main differences:
- V1 is closer to writing DSL (domain-specific language) code, as in it requires runtime engineers to write more code to declare traits and types, because everything is custom to the macro requirements in the background. This also makes understanding compilation errors more difficult.
- V2 is more heavily based on Rust idioms to define types and uses FRAME system and support crates to write code within the constraints of the macro being used. This means that if all macros were removed, the pallet would still compile as all macro inputs are correct Rust syntax, making it easier to understand where errors are coming from.
You can read more about the FRAME V1 macros here.