3 ms·
I agree with most of the criticisms of the "magic" functions, although I really have to disagree that the macro approach (with a totally custom DSL) for routing
by brundolf 4y ago
I agree with most of the criticisms of the "magic" functions, although I really have to disagree that the macro approach (with a totally custom DSL) for routing/authorization is less magical than the alternative. It also cripples IDE support. With a builder-pattern you can get smooth autocompletion and clear error messages, while macros usually sabotage error messaging and completely sabotage autocomplete.
Bigger picture: I think the reason so many Rust frameworks favor this kind of magic is to lower the bar (accessibility, but also development velocity). Being lower-level, Rust starts off with a disadvantage when it comes to quickly building out high-level application logic like you would on a typical web server, so when people are trying to expand its reach into areas like that, they try to close the gap by making their libraries as easy-to-use and boilerplate-free as they can. Rust's macro and type systems are the mechanisms it provides for eliminating boilerplate and generally making it act like a higher-level language, so that's what people use. And that makes well enough sense, even though it comes with trade-offs.