5 ms·
I like Rust a lot, but I strongly agree. “Advanced” Rust becomes as inscrutable as C++ template crap. I really wish Rust had a way to define “template style” g
by forrestthewoods 2y ago
I like Rust a lot, but I strongly agree. “Advanced” Rust becomes as inscrutable as C++ template crap.
I really wish Rust had a way to define “template style” generic functions rather than “trait style”. Some things simply can not be done gracefully with trait spaghetti.
- Ygg2 2y ago> I really wish Rust had a way to define “template style” It has! It's called proc macro [1]. I'm only half joking. [1] It can generate anything, errors generally suck ass in it as much in C++ templates and it feels similarly brittle. > “Advanced” Rust becomes as inscrutable as C++ template crap. I think people are abusing traits a bit too much. They are very nifty and often compile to very optimized code. That said this trait is not an example of such abuse. Having a trait to help with overloading is the most benign form of trait use. Solution to grandparent's problem is called rust analyzer. It will show you what methods are usable on your variable.
- inferiorhuman 2y agoCertainly it's possible to generate meaningful error messages within proc macros. Most folks don't bother though.
- forrestthewoods 2y agoRust macro hell is even worse than Rust trait spaghetti. I regularly refuse to use crates because they’re macro based and there’s a no macro alternative. But you’re not wrong :)
- tcfhgj 2y agoThere's always a no-macro alternative: expanding the macro by hand. What's macro spaghetti?
- pjmlp 2y agoI would assert it is actually worse than C++, because at least templates and constexpr execution still looks like plain C++, while macros in Rust, with two additional levels of syntax, add even more complexity.