Re:Async Rust Is A Bad Language
by radicalbyte on Friday September 08, 2023 @04:53PM
(#37439271)
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).
[ Parent
| on HN ]
I 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.
UI 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.
Wouldn’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…
I think people are looking to SwiftUI for inspiration. It'll still take some time to build and evaluate these solutions.
Re:Async Rust Is A Bad Language
by Turskarama on Friday September 08, 2023 @10:33PM
(#37441650)
It's "prefer composition over inheritance" though, not "never use inheritance".
There is a time and a place for it.
Re:Async Rust Is A Bad Language
by radicalbyte on Tuesday September 12, 2023 @01:51AM
(#37477297)
Which, as I said, results in you *usually* using composition :)