Re: Correct C++ tutorial chapter 2.1 "Classes" available (Windows, mingw/msvc/std)
Date: 30 Mar 2005 03:37:28 -0500 To: (Usenet)
Thomas Hansen wrote:
> Chris Riesbeck wrote:
> > In article <firstname.lastname@example.org>,
> > Andrew McDonagh <email@example.com> wrote:
> > > Thomas Hansen wrote:
> > > > Alf P. Steinbach wrote:
> > > > [snip]
> > > >>Contents, chapter 2.1:
> > > > I think a general "motivation" behind the REASONS to WHY
> > > > the world evolved into OOP instead of functional
> > > > programming is lacking. A big point in the whole OO
> > > > motivation the way I see it (some people will say it's a
> > > > motivation behind only C++, I'd say OO) is typesafety!
> > > > (That's why C++ is THE best OO language even though
> > > > lacking several big OO features...)
> > > I might be mis-interpreting your comments here, but type
> > > safety little to do with OO - its only relevant in UP
> > > Languages that are static typed. Dynamic typed languages
> > > exist and are also OOPLs.
> You're right off course, but both OO and strongly typing both
> try to achieve the same goal. They both want to make sure you
> don't try to fly with your submarine and go under water with
> your plain...
I'm not sure. In some ways, the goal of OO is to allow the
submarine to do whatever it has to to fly:-). (Presumably, what
it has to do is different than what a plane has to do.)
The problem with the word OO is that it has become an in thing,
so people apply it to everything. I'm not sure what it really
means any more. And while I think that there is a sense in
which you are formally right concerning type safety, I suspect
that this isn't true for the most common uses of type safety and
> OO by coupling the functions with the type and typesafety by
> making sure you have the right type for the right task.
If I understood Booch correctly, OO implies dynamic
polymorphism. If you don't have virtual functions, it isn't
OO. The type safety aspect is secondary.
> So to differentiate them in the conceptual idea is for most
> languages wrong. Most (good) languages that supports one also
> supports the other as long as it can. Off course after OO and
> typesafety came around in practical use lots of other
> "features" where added (discovered) like reuse, data hiding,
> encapsulation, cohesion and so on. But in the beginning it
> was all about denying a submarine to fly!
>>From what I understand about Smalltalk (the language for which
the word "object oriented" was invented), it was more a case of
empowering a submarine to fly, if it wanted to.
> > And there are many strongly-typed functional programming
> > languages.
> But their motivation is still the same, OO is just after all
> an extremity of typesafety.
> Instead of having a method signature with a given type and
> issuing a compiler warning/error when trying to call the
> method with the wrong type you couple the method within the
> type making it impossible to make your sub fly...
That's a particularity of C++/Eiffel/Java/Ada95. It certainly
wasn't the case in Smalltalk.
When I think of strong static typing, or type safety, I think of
the Pascal family of languages. (Pascal arguably took strong
typing too far -- the length of an array was part of the type,
and you couldn't write a procedure which took an array of a
dynamically specified length.) I'd say that the OO part of C++
is involved in loosening the type system -- in a controlled
manner, because C++ remains statically typed. Never the less,
it allows me to pass objects of different types to the same
function, which is the opposite of strong static type safety.
-- James Kanze GABI Software Conseils en informatique orientée objet/ Beratung in objektorientierter Datenverarbeitung 9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34 [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]