Maybe Erlang is OO after all?
Fri Aug 22 19:24:22 CEST 2003
On Fri, 22 Aug 2003 18:53:28 +0200
Joachim Durchholz <> wrote:
> Joe Armstrong wrote:
> > [...]
> > We can easily set-up polymorphic protocols to processes and
> > write
> > polymorphic functions (like lists:sort) - why is polymorphism so
> > nice it make programming so much easier - all objects obey the same
> > protocol (at some level of abstraction).
So who ever said programming should be easy, is what I want to know.
Polymorphism as it's usually promoted elevates the semantic<->syntactic
mapping to a human (read: fuzzy) level while obscuring the actual
working detail semantics. i.e., suddenly X.play() can have wildly
different resource requirements depending on whether X is of type Movie
or of type GameOfNim. And don't even get me started on dog.bark() vs.
tree.bark(). I'd be quite happy in a world where I had to say
X.play_video() or X.play_game_of_nim() explicitly; at least then I'd be
able to better judge what is going on merely by reading the place in the
code where it happens.
On the other hand, like overloading, sometimes it's just right - I don't
want to have to use float+ instead of int+ to add floating point values.
But likewise, cout << "hello" leaves a bad taste in my mouth - output's
relation to left-shift is fuzzy at *best*. Sure, it makes programming
"easier", like Perl's dense forest of symbols makes programming "easier"
(fewer keystrokes) - but in the long run, the more semantics that get
piled up onto the same syntax, the more context-dependent it is, and the
more there is to remember when it comes time to maintain the code.
Probably the first tenet of OO, before Polymorphism, Inheritance, and
even Encapsulation, should've been Moderation...
...but that's just not sexy.
More information about the erlang-questions