4 ms·
I share your take, and I’ll even say that classes are an underused tool when applying functional principles in mixed paradigm languages. If you use a class as a
by eyelidlessness 2y ago
I share your take, and I’ll even say that classes are an underused tool when applying functional principles in mixed paradigm languages. If you use a class as a struct (with value semantics), you get:
- A type
- A name for it
- A canonical way to build a value of that type
- A consistent way to reference its semantic meaning at runtime and in any static/build time/documentation format
- A singular, easily discoverable place to change it
- tensor 2y agoMost "non-oop" languages like Go and Rust have all of this. They also generally have interfaces. What they don't have is inheritance, which I think is what really differentiates OOP from structs with interfaces.
- eyelidlessness 2y agoEven inheritance of classes-as-structs is probably under-appreciated. It’s not quite as flexible as more general composition. But it’s not nearly as problematic as OOP inheritance, because it’s ultimately only a hierarchical composition of taxonomy and value construction semantics. It can become problematic if you apply the wrong taxonomy, but that would be true without inheritance as well.