Comment by maplant
2 days ago
This is pretty easy to understand if you have a cursory understanding of Rust and HTML.
I won't get into the HTML part (I think it's obvious), but the
$(|_e| count.increment())
part is a rust closure. |_e| is the argument to the closure, which has a leading underscore because it's unused. I imagine it's some context about the event (thus the e). The rest is the body of the closure. It increments the count.
pretty simply
GP is pointing out this introduces this kind of special DSL syntax with HTML tags into a procedural/functional language like rust?
Even though macros can do this, it's not intuitive to expect this kind of JSX soup in rust. It's difficult to reason about than a function call. Something like flutter where widgets are ordinary function calls is far better.
Plus the macros add to the compile time tax.
This is another exhibit that rust is full of web programmers from React JS world (the above is exactly like JSX), all about aesthetics than practicality and predictability these days, pulling what should be a system language into incompatible directions.
Long live zig for trying engineering directions rust couldn't. But we need a rust killer with memory safety which gatekeeps web programmers and slop peddlers.
One of the main designers of this has a lot of flutter projects and no JSX projects on their github so I have no idea what you're on about. They also have a YouTube channel dedicated to their C++ voxel game engine https://www.youtube.com/channel/UCDye5hFy14hdQGohhqpY6LQ
It's a bad design regardless, borrowing from JSX playbook.