logoalt Hacker News

llmslave2last Wednesday at 7:25 AM2 repliesview on HN

Inheritance is great, just depends how you use it.

I've never once reached for it for building servers.

For games? All the time.


Replies

flohofwoelast Wednesday at 8:03 AM

> For games? All the time.

Hmm, but game objects is exactly the popular use case where traditional inheritance breaks down first and composition makes much more sense? That's why the whole Entity-Component idea came up decades ago (like in Unity, long before the more modern column-database-like ECS designs).

show 1 reply
echelonlast Wednesday at 7:34 AM

The only two domains where I've felt inheritance is useful are video games and windowing systems.

Inheritance is actually useful for Widget > Input > TextBox since methods and behaviors do follow parent-child and even sibling relationships.

But there aren't many domains like this.

Rust and other languages choosing traits and type classes instead of strict species-oriented class inheritance seems like the much more modern and more widely applicable approach.

Classes feel clinical and dated.

show 2 replies