Re:The Unsound Playground: Java and Scala's Type Systems are...
by willtim on Monday November 28, 2016 @01:00AM
(#13053696)
Taxonomies are common in the real world, so it is natural to try to model them. If the language lacks sum types (the mathematical dual of product types, a.k.a. tagged unions) then programmers are forced into using inheritance to encode it. So I blame the language, not the programmers.
[ Parent
| on HN ]
Re:The Unsound Playground: Java and Scala's Type Systems are...
by gregoor on Monday November 28, 2016 @03:05AM
(#13054079)
I understood JP's critique to be more about mixing behaviour with data than about alternative ways of modelling inheritance.
Re:The Unsound Playground: Java and Scala's Type Systems are...
by willtim on Monday November 28, 2016 @12:47PM
(#13057031)
But Java strongly encourages the mixing of data and behaviour. There is only virtual method dispatch and switch on ints/enums for efficient case analysis. We therefore need complex encodings like the Visitor pattern, if we are to avoid conflating data and behaviour. So again, I blame the language not the programmers.