6 ms·
> That's why we get so many complaints from C++ and D developers that you can't do certain things. But Rust sticks with its strongly-typed generics, because Rus
by EvenThisAcronym 11y ago
> That's why we get so many complaints from C++ and D developers that you can't do certain things. But Rust sticks with its strongly-typed generics, because Rust has always tried hard to strike a balance between code expressivity and maintainability.
In what sense are Rust macros "strongly-typed"? D and C++ templates are also strongly typed, just like the rest of the language.
- pcwalton 11y agoRust generics are strongly typed. C++ and D templates are, however, untyped. You can get errors at template instantiation time in C++ and D, because the compiler makes no attempt to ensure that the types your template operates on actually support the operations you're performing on them at the time you declare the template. In Rust (and basically every other language), though, the compiler typechecks your templates at the time you write them, so template instantiation can never result in errors inside the template.
- EvenThisAcronym 11y agoAh, I see. I'm assuming then that Rust generics are not generative templates like C++/D, but closer to Java/C#.
- comex 11y agoThey're like Java/C# syntactically. Implementation-wise, they're monomorphized (code is generated for each specialization at compile time) like C++.