News for hackers. Stuff that matters.
Re:Toasty, an Async ORM for Rust by simonask on Saturday October 26, 2024 @05:16AM (#41953620)
I mostly agree with this, but the trouble is (probably) that proc-macros are heavy-handed, inflexible, and not great for compile times.

In this case, for example, it looks like the generated code needs global knowledge of related ORM types in the data model, and that just isn't supported by proc-macros. You could push some of that into the trait system, but it would be complex to the point where a custom DSL starts to look appealing.

Proc-macros also cannot be run "offline", i.e. you can't commit their output to version control. They run every time the compiler runs, slowing down `cargo check` and rust-analyzer.

Re:Toasty, an Async ORM for Rust by trevyn on Saturday October 26, 2024 @08:13AM (#41954274)
You can absolutely do global knowledge in proc macros via the filesystem and commit their output to version control: https://github.com/trevyn/turbosql
Re:Toasty, an Async ORM for Rust by simonask on Monday October 28, 2024 @06:50PM (#41977381)
You can introduce side effects to a proc macro (but please avoid if at all possible), but you cannot control the order in which proc macros are run. If you need to reason about the global schema while generating code, that won’t work.