[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions for a language designer

> Date: Wed, 28 May 2003 11:52:57 -0400
> From: Scott McKay <swm@itasoftware.com>
> I also wonder if languages that had more up-front design
> have clearer answers to these questions.  I was thinking
> about a bunch of languages last night and this morning,
> and lots of them neatly answer a lot of the questions,
> such as C, FORTRAN, Lisp, Dylan, Java, Pascal, ML, Haskell,
> Python, ...  There were two in particular that I had a hard
> time categorizing: C++ and Perl.
> For example, C++ tries to do generic object orientation
> two different ways, via classes and via templates.  It's
> got several ways of passing arguments.  It's got syntactic
> extensions, but as an abuse of templates.  And so on.  Does
> this reflect on its accreted nature?  If so, why do various
> dialects of Lisp feel more consistent to me?

Templates don't actually do object orientation.  They were intended to
provide a parameterization over types (what is called parametric
polymorphism in ML and Haskell), but in order to achieve maximal
efficiency, they do this using macro-expansion.  In my view this is totally
orthogonal to object orientation.  Inheritance is a mechanism for extending
types, whereas templates are a mechanism for parameterizing over types.

Bertrand Meyer has a pretty good discussion of these issues in his book
"Object-Oriented Software Construction".