Why not just add classes?

Worth note along the way that while macros are way better in Rust than in C or C++, they're still a bit of a mess. See some of the discussion in this thread, where I got schooled on a whole bunch of those limitations, for more. See also Nick Cameron's blog posts about his hopes for substantially improving the macro system over the year ahead.

On the OP: Rust isn't just a "better C"; it's at least equally what Sean Griffin has called "a more practical Haskell." The syntactical similarity to C-descended languages (and current marketing, which I fully appreciate) notwithstanding, Rust borrows a lot of ideas from Haskell and ML-family languages in its approach to code reuse, and to types in general. So it's a real shift paradigm-wise from the C++, Java, or C# styles of inheritance (or even Python's), but one that, once you get used to it, makes the old version feel like a straitjacket when you go back.

8 Likes