3 ms·
It definitely works differently to C++/Java/Python, but IMO this is one place where Rust is a huge improvement. You are effectively always generic over an inter
by nicoburns 4y ago
It definitely works differently to C++/Java/Python, but IMO this is one place where Rust is a huge improvement. You are effectively always generic over an interface (trait in Rust) rather than a base class, and this is much more flexible as a given strict can implement as many interfaces as it likes rather than being stuck in one class hierarchy (or having to deal with the pain of multiple inheritance)
- pjmlp 4y agoIt is no different than using interfaces, protocols, pure virtual base classes....
- dllthomas 4y agoIt's similar, but there are some differences. Notably, my package can implement my trait for your type, while my package (usually? always?) cannot make your type inherit from my virtual base class.
- pjmlp 4y agoDepends on the flexibitly of the language, there isn't a golden way to do that across all variations of OOP.
- eklavya 4y agoWrapper classes should be equally good once Valhalla (jdk) lands, without introducing another pointer indirection.
- adamc 4y agoInteresting but Java gets more and more complex in a way that does not make me want to write things in Java.