Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yes, I'd argue COM is specifically very limited in such a way that traits can be used to implement it mostly seamlessly. But regardless, the dispute is over "[Rust and C++] encourages creating a library of types with inheritance".

Anyone who has at least read and understood both of these languages can see that this is not true, even if you replace inheritance with traits in rust. Not only that, traits do not support the same range of things that inheritance does. They have overlap, but it's not a small difference. When you actually get down to real rust codebases, they end up pretty different even if they're heavy on traits. But again, there's nothing requiring you to use traits. You see them often in libraries because they are very useful for generic programming. But that doesn't mean you are forced to use them in your application code.



You are making the mistake to confuse inheritance with class inheritance.

There is also interface inheritance, which Rust allows for with trait bounds composition, now made even easier with trait upcasting.

With some macro help, one can even do COM style of multiple interface implementation with aggregation and delegation, to simulate class inheritance, like ATL allows for with template metaprogramming.


Rust doesn't have interface inheritance either.

Rust only has composition in this regard. Calling it inheritance in any way is just confusing terminology.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: