5 ms·
To name one example: Because it still allows you to write to a higher level of abstraction. So you can have all sorts of different data storage classes - lists
by bunderbunder 8y ago
To name one example:
Because it still allows you to write to a higher level of abstraction. So you can have all sorts of different data storage classes - lists, sets, hash maps, etc. - and decide that they all implement an "enumerable" interface, and then any functions that just need to be able to apply some operation to every element in a collection can work with every single one of your collection types.
Haskell has ways of getting us that sort of thing with only structs and bare functions - and does a really nice job of it, too - but most of us aren't working in Haskell.
- kccqzy 8y agoYou are mixing different concerns. The Haskell example you are talking about is just interfaces, not classes. As for data abstraction, we can use modules; either the weak Haskell ones or better ML ones. Classes simply conflate the two concepts. I'd rather remove the feature of classes and introduce those two instead.