Java inheritance is a kludge

The real reason inheritance gets heavily used is that it’s the only way to do polymorphism in languages with really naive static nominal typing (like Java).

With structural typing, you’ve basically separated out interface from implementation, so you don’t need to have any preplanned assocation between different implementations (let alone a hierarchy). With derived types, you don’t need to actually declare which types you take, so you don’t need to abuse the type system to allow more than you’re technically allowed to pass (by creating a do-nothing interface to group together…



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store