Bill Pursell said:
[...] I conclude that you
think C++ is not an object-oriented language.
"I invented the term Object-Oriented, and I can tell you I did not have
C++ in mind." - attr Alan Kay
Nevertheless, C++ does provide a certain amount of support for OOP.
Overall,
I'm trying to understand why it is that people seem
to have the attitude of "OOP is great, C is dead" but
don't seem to realize that OOP is often nothing more
than taking all the good programming practices that
were being used by C programmers through the 80's
and making them (arguably) easier to use. I
respect you as a contributer to c.l.c., so I was
hoping to get you to elaborate on your position.
Gladly. Here's a quote from my Web site:
*** begin quote ***
Ada. APL. Assembly language. B. Basic. BCPL. C. C+. C++. C#. COBOL. D.
Forth. Fortran. Haskell. Java. Lisp. Logo. Pascal. Perl. Prolog.
Python. Scheme. SNOBOL.
Is your favourite language mentioned in that list? If so, are you
feeling smug? Or if not, are you outraged?
There are, quite literally, thousands of computer programming languages,
and it seems that every single one has more than its fair share of
passionate advocates. Whichever language you are using, you will
generally find far more people telling you that your choice was wrong,
than people who will agree that you made a reasonable decision to use
that language.
C diehards (er, like me!) will give you several excellent reasons why C
should be your language of choice. C++ aficionados will be just as
persuasive about C++, and often disparaging about C (they call it "a
better C"; I'd be happier if they called it "a different C", but of
course they don't). Ada lovers will typically look down their noses on
both the C and the C++ camp. Visual Basic programmers don't understand
what the fuss is about, since it's quite obvious to them that you can
do anything you need to do in straight VB code. And there's always some
smart alec who'll point out that using such high level languages can
only lead to code bloat and runtime inefficiency; assembly language is
the only way to go. COBOL programmers will then point out that the
whole point of COBOL is that you don't have to use assembly language.
And then the Pascal programmers will retort that the whole idea of
Pascal is that you don't have to use COBOL. Fans of functional
languages such as Lisp will then say that, if you haven't programmed
functionally, you haven't really understood programming at all!
Why are we so passionate about our choice of computer programming
language? Do other professions suffer from the same damaging
phenomenon? Can we imagine builders arguing about hammers? Or plumbers
arguing about wrenches?
The answer probably lies in the close relationship between language and
thought. Language doesn't just enable us to express ourselves. It also,
to a very large extent, controls and limits the ways in which we can
think. It is almost impossible to think like a Spaniard, for example,
unless you happen to be Spanish (or, at the very least, to speak
Spanish very fluently indeed). And because Spaniards cannot, on the
whole, imagine with any accuracy what it is like to be non-Spanish,
they are likely to conclude that being Spanish is the best way to be.
(There is nothing special about Spaniards in this regard, of course --
I could have chosen any nation on the planet for the purposes of the
example.)
And so it is with computer programming languages. For a start, a
programmer who "speaks" only one programming language is likely, in the
medium term, to have his thought processes so moulded, so shaped, by
that language that he finds it hard to imagine that there are other
ways to program; and, if there are other ways, well, they must surely
be inferior, mustn't they?
But this is a very limiting way to look at programming languages. A
programmer who has taken the very sensible course of learning several
programming languages is in a much better position to judge between
them. And yet, curiously, such programmers tend to be dispassionate
and, dare I say, rational about language choice. For them, the sensible
thing to do is to choose the language that best fits the problem
domain.
For example, consider a programmer who is fluent in C, has adequate C++,
and can boast a smattering of COBOL, assembly language, and Visual
Basic. He is asked to write a program to check documents, presented as
text files, for heavily-used phrases (perhaps he works in a publishing
house, and the program is intended to help authors to identify clichés
in their books; as we all know, clichés are a Bad Thing, and good
writers avoid them like the plague).
Since no platform was mentioned, the programmer may reject Visual Basic
out of hand (since he can't guarantee that his program will be run
under the Windows operating system). Similar considerations, and the
sheer amount of work it would involve, lead him to reject assembly
language too. COBOL isn't terribly well-designed for such a task, so he
is left with C or C++. His fluency in C might lead him to favour that
option at first, but on reflection he will realise that C++'s STL will
literally turn this task into a one-hour job at the most, and possibly
a much shorter time need be spent. That doesn't mean C++ is the right
choice for all tasks. But he may well conclude that it's the right
language for this task.
He will also be wise enough to recognise that there may well be
languages which are better suited to the task, but he will rightly
decide that, at least for the time being, it'd be quicker to use a
slightly less suitable language that one knows than to spend the time
learning a completely new language, and then still have to invest yet
more time in writing the program itself in that language (and writing
programs in a language you don't know very well is almost bound to take
longer than writing the same programs in a language that you do know).
If he is very wise indeed, he will make a point of learning that other
language anyway (perhaps once he's finished his current task), so that
the next time such a task is presented to him, he'll be ready.
There are so many different languages because there are so many
different ways to think about programming. The language that is most
right for me may not be the language that is most right for you. So
what right have I to tell you what language to use? And what right do
you have to tell me what language to use? None whatsoever, right?
So please, let's have a little sanity when it comes to language wars.
Just remember that one man's meat is another man's poison. Cultural
diversity is just as important and rewarding in programming as it is in
other aspects of our existence here on Earth. Our time here is not so
protracted that we can afford to waste any of it insisting that other
people should change their way of thinking just because we are too lazy
to change ours.
Use C. There's no better language. :-)
*** end quote ***
My position seems to be: "OOP is good, although the
definition is ambiguous, but C++ is heinous, (but
slightly less heinous than I thought 6 months ago.)"
C++ is a reasonable language, albeit very complicated. The mistake many
people make is in thinking you have to program it the way the C++ fans
do. You don't. It's much more flexible than that. You can program it
any way you please (within the bounds of syntax, semantics, and a
smattering of common sense). And that's one thing I admire about C++.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.