<pop@cs.umass.edu> writes:
C++ on the other hand
is a superstructure erected on the hull of C that is really just too big,
and which is prevented from offering the security of an advanced language
because of the loopholes in C.
There are three misconceptions here. Firstly, C++ and C are different
languages. I have two compilers on my Mac at home: a C compiler with
object extensions and a C++ compiler. I admit that the syntax of the
programs written for the C compiler with object extensions looks very
much like C++, but the semantics is different. (No, I'm not being
rude about a poor implementation of some alleged "C++" - both products
come in the same box from the same vendor, and object modules produced
by them can be linked together.)
Secondly, it is quite possible to write secure programs in C++. You can
even use smart pointers, garbage collecting classes etc. if you don't
want to think about memory management. The facilities for encapsulation
and data hiding in C++ are very good - the syntax is awful, IMHO, but
the facilities are better than in any of the other languages I use
regularly. Maybe I've misunderstood what pop means by "security"? If
he means it is possible to write programs with bugs in, then I would
answer that I can write programs with bugs in any language (if I
try hard :-). Maybe he is thinking about using raw pointers (as is
common in C programs)? But you can do that in Poplog if you want
to deliberately scribble all over memory (and in most Lisp systems
too, once you work out how). There is no reason to do it in C++,
very little use is made of pointers in a well-designed C++ program.
One of the problems with critiques of C++ is that very often they are
based on an understanding of C, OOP and a quick skim through an
introduction to the syntax of C++. Very few programs compiled with
C++ compilers are C++ programs - mostly they are C programs (yes,
although the languages are different, a lot of backward compatibility
was a design goal) even if they use classes instead of structs to give a
bit of data hiding.
Every competent (and not-so-competent) programmer that I know who has
learnt C++, even when they are already familiar with both OOP techniques
and with C, has found that learning C++ takes *much* longer than they
expected. In my case, it took me about 6 months elapsed time to
feel comfortable that I was writing C++ programs (rather than something
that would compile through a C++ compiler: there is a big difference).
This was about five and a half months longer than I expected. There are
a *lot* of new idioms to learn. If you think you know C++, let me ask
if you automatically use the "protected" keyword instead of "private"
or "public" when appropriate? Have you used "private" inheritance?
Virtual (as opposed to non-virtual) base classes?
Third misconception: C++ is not a large language. It is quite a bit
larger than C, but compared with Common Lisp (or even Pop11) it is not
large. And CLOS is huge in comparison.
Having said all that, I'm not actually a C++ fan. I have to use the
language in my work, but I prefer to prototype in Lisp (pop11 would do -
but is not available on the machines I develop on).
Regards,
Jonathan Cunningham
It ain't what you know, but the way that you know it.
|