| To be honest, I am not so convinced about classes as units of program organization either. Classes conflate in a single mechanism several concepts: 1. Types (classes) 2. Encapsulation (private, protected) 3. Polymorphism (virtuals) 4. Code reuse (inheritance) While it is much better than prototypal inheritance, it is still less than ideal. On the other hand, there are languages like Haskell and ML which compartmentalize better these concepts: 1. Types: algebraic data types and type synonyms 2. Encapsulation: modules 3. Polymorphism: type constructors (parametric), type classes (ad-hoc, Haskell only) 4. Code reuse: derived type classes (Haskell only), functors (ML only) The result of providing these features independently from one another is a net increase in flexibility. You can have, say, a module that exports two or more types, and a single function inside that module that can manipulate the internals of both types. === Edit: And Rust gets this right as well, of course! 1. Types: structs and enums 2. Encapsulation: modules and crates 3. Polymorphism: generics (parametric) and traits (ad-hoc) 4. Code reuse: trait inheritance and trait instances for generic types |