You are not logged in. Login Now
 0-10          
 
Author Message
cross
The C++ item Mark Unseen   Sep 16 23:09 UTC 2006

This item is for discussing the C++ programming language, created by Bjarne
Stroustrup at Bell Labs.  C++ is, as its name implies, an extension of C.
Stroustrup was interested in modeling systems as a graduate program, and
encountered the Simula language.  Upon arrival at the labs, he experimented
with adding Simula-like class features to C, and did so.  His "C with
classes" language grew and acquired new features, including a template
structure that facilities generic programming, a rich template library
including algorithm and data structure implementations, an exception
facility and an extensive standard library.

C++'s greatest strength is also its greatest weakness: its C heritage and
compatibility.  C++ code can generally be linked against the vast amount of
legacy C code, and standard conformant C code will often compile as C code.
But with this comes much of the baggage of C including the problems
associated with pointers and other low-level constructs.  Further, subtle
semantic differences between C and C++ can manifest themsevles as strange
bugs.

C++ is also criticized for being simply too complex.  Stroustrup himself has
said that there is no single person who understands all of the language.
C++ is considered difficult for beginners and only experts are thought to
truly understand its object facilities.  Further, this complexity has given
C++ a (perhaps undeserved) reputation for being slow and inefficient.  In
reality, if care is taken by the programmer, C++ code can be quite nimble.
However, it takes a lot of understanding of the language and its semantics
to make this happen, and compilers can't help as much as they can for other
languages because they are hampered by the pointer system, among other
things.

Regardless, C++ has become a popular applications programming language.  It
offers a nice mixture of C's expressiveness and other language's features.
The standard template library and exception handling facilities make it more
convenient for many programming tasks than C, and this is reflected by the
number of large systems that have been implemented in it.
10 responses total.
gull
response 1 of 10: Mark Unseen   Sep 18 18:52 UTC 2006

When I was in college, for some reason they thought they should start 
us out on C++ without teaching us C first.
remmers
response 2 of 10: Mark Unseen   Sep 18 21:20 UTC 2006

When I was in college, neither C nor C++ had been invented yet.  I doubt 
that C was even a gleam in the eye of my classmate Dennis Ritchie.  
However, many many years later, when I was teaching college, my department 
decided they should switch from Pascal to C++ as the first programming 
language.  Personally I'd have preferred C.  The results were kind of 
unsatisfactory -- some instructors (like me) taught more or less the C 
subset of C++ in the first course, while others focused on OOP from day 
one.  After a few years of putting up with this, we switched to Java.

C++ has always struck me as kind of a hodge-podge everything-but-the-
kitchen-sink kind of language.
cross
response 3 of 10: Mark Unseen   Sep 19 03:20 UTC 2006

Stroustrup wrote an interesting paper on teaching C++, in which he says NOT
to teach C or the C subset of C++, but rather to teach C++ as C++ (not
necessarily the OO facilities, nor the bits and bytes of C).  It's an
interesting paper, and available here:

http://www.research.att.com/~bs/new_learning.pdf

John, I'd be interested in your view point on it, since you taught C++ in a
classroom environment.

I do think your criticism is valid, though; I feel the same way about C++.
But, it can be a useful tool for writing real-world applications, fitting
somewhere between C and Java.
sholmes
response 4 of 10: Mark Unseen   Sep 19 05:23 UTC 2006

If given an option on choosing between C++ and Java for implementation, what
issues are relevant in making that decision ? [ If we leave out performance
issues, that i am under the impression that C++ wins hands down but Java is
alsocatching up]
gull
response 5 of 10: Mark Unseen   Sep 19 06:39 UTC 2006

One of my complaints is that this was a course for people not majoring 
in computer science.  If you're going into an engineering or system 
administration sort of field, C is going to be much more useful to know 
than C++.
cross
response 6 of 10: Mark Unseen   Sep 20 04:03 UTC 2006

Regarding #4; I think performance might be the number one.  Another would be
interfaces to legacy code; if you have a library in C that you need (or want)
to use, then you can write a JNI wrapper for it, or just use C++.  You might
also be influenced by the skillsets of the programmers involved, target
platforms, etc.  Also, maintainability, the "coolness" factor, and others all
weigh in.  In general, C++ has in its favor compilers for just about any
platform (suprisingly, unlike Java), speed, the ability to interface with
existing C and C++ code, and the maturity of an older language.  Java has in
its favor a purer object model, a rich standard library, arguably better
maintainability (certainly better "safety"), and bytecode portability.

Unfortunately, one of the tendancies I've seen with Java (and to a lesser
extent C++) is that, because it's (arguably) more maintainable and safer, you
tend to see far more complex code written in it.  So, its strengths are also
an invitation to complexity, which is a weakness.  But that's a programmer
issue more than a language issue.

Regarding #5; While a working knowledge of C is certainly a useful thing for
many fields, I'm not sure I'd agree that it's substantially more useful than
knowledge of C++.  In particular, C++'s richer abstraction capabilities can
be exploited to better model, say, engineering problems at a higher level,
which can be a big win.  With C, one often finds oneself bogged down in things
like string manipulation routines that are already provided by C++'s standard
string class, or with building containers for various objects, where C++ has
the STL (which can be useful for building collections of objects that model
engineering constructs; for instance, a bridge is a collection of cables and
beams, rivets, etc...).
gull
response 7 of 10: Mark Unseen   Sep 20 23:19 UTC 2006

That's true.  But if you're dealing with other people's code, you're 
much likelier to find C than C++ "in the wild."  This seems to be 
especially true when the target platform is something embedded.
cross
response 8 of 10: Mark Unseen   Sep 20 23:29 UTC 2006

Hmm.  Perhaps.  On a related issue, I've always found it more fruitful to
approach teaching programming from the, "here's what you need to know to be
a good programmer" perspective as opposed to the, "here's how to program in
<insert language here>."  The former transfers from language to language
better.  Programming languages, like natural languages, are not easily learned
in the classroom, and certainly not retained.  You have to be imersed in them.
I suppose, though, that any little bit might help.
gull
response 9 of 10: Mark Unseen   Sep 21 16:42 UTC 2006

That's true.  It's the concepts underlying how to program that are 
really important; the language itself is just details.  That's why it's 
relatively easy for an experienced programmer to pick up a new 
language.
cross
response 10 of 10: Mark Unseen   Sep 21 19:32 UTC 2006

Yes.
 0-10          
Response Not Possible: You are Not Logged In
 

- Backtalk version 1.3.30 - Copyright 1996-2006, Jan Wolter and Steve Weiss