Hacker News new | ask | show | jobs
by thenaturalist 330 days ago
> classes are a bad way to model data imo

Genuinely curious: why?

1 comments

Not the one you’re replying to, but my take: The main problem with classes is that they conflate a lot of concepts that should be separate and you usually need only one or a few at once, but are 5orced into all of them. Namely:

• Product type

• Reference semantics

• Namespacing

• Pipeline-style call syntax

• Redefinition of infix operators

• Dynamic dispatch

• Subtyping

For example, you cannot have a product type with value semantics or a type that redefines infix operators but is not a product type.