Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've seen people encounter this problem and say, "OO hierarchy is broken for programming." This is the wrong message to get; for many problems simple linearizable hierarchies are very useful.

What's broken is relying solely upon this mechanism to express all relationships. When your only relations are "Has" and "Is", even English would be hard pressed to express things elegantly.



English has no problems saying that a circle is an ellipse, though. Neither does math. I'd like my programming languages to be able to express math.


"is like" is not in the vocabulary in many OO languages, and that's the rub. A circle is not (in a general, behavioral sense) an elipse and can't support all the operations an ellipse is expected to do.

As for asking for expressing math, things like CL's generic methods or Haskell's typeclasses model this sort of ad hoc series of relationships much more elegantly, in my opinion.


Haskell's typeclasses are still a few hacks away from perfection :-) See the last part of this document: http://www.haskell.org/tutorial/numbers.html


The rub comes when one tries to hang behaviour on the types.


What other relations should there be? Would there be a form of "is sorta like, but..."? (Seriously, actually. This is somewhat like a mixin.)


Supports behavior/interface-of?

"X is Y" in English (and math) seems to have different implications than "X IS-A Y" does in statically typed, class-based OOP.


Yes, but that's IS-A in a very absolute way. There are all sorts of softer uses of "is" in English, often in combination with modifiers.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: