Hacker News new | ask | show | jobs
by wereHamster 3451 days ago
You can achieve the same with composition or parametrisation. Both of which are the only tools in a functional language.
2 comments

You can achieve the same in any Turing complete language.

However, composition and parametrization require up-front design and are usually only viable for large-ish variations.

As the parent said, inheritance handles the case of refinement, that is, programming by difference, which composition and parametrization handle with difficulty (if planned for) or not at all (if not planned for).

The bad rap inheritance gets is that it is often misused in places where composition or parametrization were appropriate. But that's just the old "it hurts when I poke myself in the eye with a sharp stick": don't do that.

http://www.metaobject.com/papers/Diplomarbeit.pdf

If you include interfaces you've essentially split inheritance into separate parts. Which isn't necessarily a bad idea.