3 ms·
I'm from the C# world and am working through learning Rust... in C# we've largely moved away from using inheritance. Not sure that it's a good thing but "best p
by radicalbyte 3y ago
I'm from the C# world and am working through learning Rust... in C# we've largely moved away from using inheritance. Not sure that it's a good thing but "best practise" results in serialisation being implemented differently (serialisers which use attributes, or for more advanced teams serialisation wired in at compile time targeted by attributes - advantage here being that the state doesn't have to be public).
- wvenable 3y agoI still use inheritance in C# although it is only used for is-a relationships and those aren't that common. But when you need it for that, it's usually pretty important. I also think it's much more common to see it in library / framework code and not in application code.
- vacuity 3y agoUI in Rust without inheritance is tricky. There's still no great UI framework written in Rust yet, though not for lack of trying! I'm interested to see how Bevy's UI turns out. They're currently exploring the design space and requirements for production-grade UI, actually.
- twodave 3y agoWouldn’t something akin to swift UI work well in this situation? I can understand that not having a “component” class to inherit would make building custom components difficult, but if most layout and skinning can be accomplish via functions then you can sidestep the issue for most cases I think…
- vacuity 3y agoI think people are looking to SwiftUI for inspiration. It'll still take some time to build and evaluate these solutions.
- Turskarama 3y agoIt's "prefer composition over inheritance" though, not "never use inheritance". There is a time and a place for it.
- radicalbyte 3y agoWhich, as I said, results in you *usually* using composition :)