Advantages of C++ over C - request for information

  • Thread starter Kamil Burzynski
  • Start date
K

Kamil Burzynski

Hello.

I have to create short (1 hour) presentation about C++ advantages over
C. Are there any good articles/texts/etc. about such topic?

Personally, I'm quite proficient at C++ myself (e.g. I've read and
understood many books from H. Sutter, A. Alexandrescu etc.), so I do not
need to learn about C++ before making that presentation. I am able to
write such presentation myself, but of course - if somebody else written
similar text, I would like to use it.

Thanks in advance for any ideas, comments and pointers to articles.
 
A

Andrew Koenig

I have to create short (1 hour) presentation about C++ advantages over
C. Are there any good articles/texts/etc. about such topic?

Take a look at chapter 1 of 'Ruminations on C++."

Also, here's an example:

map<string, int> words;
string word;

while (cin >> word)
++words[word];

This code fragment counts how many times each distinct word appears in the
standard input stream. You might try rewriting it in C and see how much
more code it takes.
 
K

Kamil Burzynski

Take a look at chapter 1 of 'Ruminations on C++."

Also, here's an example:

map<string, int> words;
string word;

while (cin >> word)
++words[word];

This code fragment counts how many times each distinct word appears in the
standard input stream. You might try rewriting it in C and see how much
more code it takes.

Thanks a lot - great example! By the way: any similar example for type traits,
some advanced template<> (i.e. something more than containers) snippets?
 
D

Daniel Haude

On Mon, 7 Mar 2005 16:34:24 +0100,
in Msg. said:
I have to create short (1 hour) presentation about C++ advantages over
C. Are there any good articles/texts/etc. about such topic?

That's an odd topic. Any talk entitled "The advantages of A over B" sounds
like a misguided attempt to sell product A to a customer who prefers B.
But if this was the case it would be better to entitle the talk "On the
differences between A and B", which of course would also unveil the
advantages that B has over A.

And 1 hour is by no means "short". What's the background of this question?
Just curious.

--Daniel
 
K

Kamil Burzynski

That's an odd topic. Any talk entitled "The advantages of A over B" sounds
like a misguided attempt to sell product A to a customer who prefers B.
But if this was the case it would be better to entitle the talk "On the
differences between A and B", which of course would also unveil the
advantages that B has over A.

Good point. This situation is slightly similar, however :) Take a look
below for more explaination.
And 1 hour is by no means "short". What's the background of this question?
Just curious.

Well, lets say, that "long" is few days - 8h each ;)

There is many C programmers, that do avoid C++ just because "it is too
bloated, C++ are bigger and slower, I can use struct instead of class and have
rougly the same functionality, etc.". I would like to show, that C++
is not necessarily overbloated, and it have many useful mechanisms, that
are improving programmers efficiency on long-term project development.
 
N

Noah Roberts

Kamil said:
Hello.

I have to create short (1 hour) presentation about C++ advantages over
C. Are there any good articles/texts/etc. about such topic?

Don't forget to mention that C++ is C with two plusses...
 
O

osmium

Kamil Burzynski said:
I have to create short (1 hour) presentation about C++ advantages over
C. Are there any good articles/texts/etc. about such topic?

Personally, I'm quite proficient at C++ myself (e.g. I've read and
understood many books from H. Sutter, A. Alexandrescu etc.), so I do not
need to learn about C++ before making that presentation. I am able to
write such presentation myself, but of course - if somebody else written
similar text, I would like to use it.

Thanks in advance for any ideas, comments and pointers to articles.

Try Bjarne Stroustup's site:

http://www.research.att.com/~bs/C++.html

I haven't looked but there must be some good stuff there. I know he has a
good list of advantages in the Second Edition of _The C++ Programming
Language_.
 
A

Amit Pansare

Kamil said:
Hello.

I have to create short (1 hour) presentation about C++ advantages over
C. Are there any good articles/texts/etc. about such topic?

Personally, I'm quite proficient at C++ myself (e.g. I've read and
understood many books from H. Sutter, A. Alexandrescu etc.), so I do not
need to learn about C++ before making that presentation. I am able to
write such presentation myself, but of course - if somebody else written
similar text, I would like to use it.

Thanks in advance for any ideas, comments and pointers to articles.
1> new /delete vs malloc?
2> inline constructors and destructors for better performance?
3> How do we acccess struct data? Using some array indexing -- so isn't
that overhead?
4> What about locality of reference in c++ isnt it much better?

You can talk about these points as well.
 
P

Phil Staite

Kamil said:
There is many C programmers, that do avoid C++ just because "it is too
bloated, C++ are bigger and slower, I can use struct instead of class and have
rougly the same functionality, etc.". I would like to show, that C++
is not necessarily overbloated, and it have many useful mechanisms, that
are improving programmers efficiency on long-term project development.

If you're trying to sell/promote/discuss C++ rationally with a bunch of
die-hard C programmers (I oughta know, I used to be one many years ago)...

Then maybe they are already thinking object-oriented, packaging data up
in structs and writing functions to work with structs. (ie. almost like
member functions) You could point out:

C++ increases type safety, particularly with new, delete, collection
classes and stream IO. This enables you to catch some errors at compile
time rather than debugger time.

C++ provides automated "plumbing" for doing what they are already doing
"by hand." If they are thinking/coding object oriented (yes you can do
that in C) then using an OO language just makes life easier.

C++ provides virtual functions, something not easily done in raw C. (yes
I know you can. But hey, I can whittle a rocking chair with nothing
more than a pocket knife too, but why would anyone want to?)

C++ gives you the STL, letting you "stand on the shoulders of giants" -
or at least not have to re-invent fundamental data structures and
algorithms.

C++ provides an exception mechanism for structured error handling.

C++ is not nearly as big and bloated as many C die-hards (and assembly
programmers) would have us believe. Can you hurt yourself (and
performance) with C++? Sure. But you can also write code that is every
bit as efficient as C. When people complain that C++ is big and
bloated, it often means that their understanding of the problem and how
best to apply OO/C++ to it is anemic.

Finally, they don't have to try to go whole-hog into C++ from day one.
They can start out simply using C++ as a better C. Then begin applying
C++ idioms as appropriate.
 
G

Gianni Mariani

Phil said:
Kamil Burzynski wrote: ....
C++ is not nearly as big and bloated as many C die-hards (and assembly
programmers) would have us believe. Can you hurt yourself (and
performance) with C++? Sure. But you can also write code that is every
bit as efficient as C.

Translation: "I can write bad code in any language."


When people complain that C++ is big and
bloated, it often means that their understanding of the problem and how
best to apply OO/C++ to it is anemic.

Finally, they don't have to try to go whole-hog into C++ from day one.
They can start out simply using C++ as a better C. Then begin applying
C++ idioms as appropriate.

I'm not sure this is appropriate (after having done just that)!

I would rather introduce tools like smart pointers, policy classes etc
right up front. The learning curve will be shorter (hopefully).
 
E

eed132

I hear this is the approach "Accelerated C++" takes, though I havent'
seen this book myself. (I wish I had heard of it it 7 years or so ago
though, if it was around then.)

I'm actually "writing" (when I have the time, which is essentially
never) what will be a full-fledged book I'm going to put online that
takes this approach too.
 
T

Taras

Why is that an advantage? Takes almost 200% longer to type...


All the things you are writing in C++ can be written in C.
Advantage of C++ is that you can do it faster, with less
errors and so on. This is starting point to all other
explanations. Otherwise you will always get answer
"I can do it in my beloved C".
 
D

Daniel Haude

On Tue, 08 Mar 2005 10:43:35 +0200,
in Msg. said:
All the things you are writing in C++ can be written in C.
Advantage of C++ is that you can do it faster, with less
errors and so on.

Depends very much on the application though. I learned C++ when I was
faced with a problem that was so compulsively object-oriented that
learning the new language and implementing the application was a lot
faster than it would have been in C. In fact I didn't have to work very
hard because I had negotiated for a very convenient deadline (thinking I
would use C. In C++, I had the parts of the app ready long before the
respective deadlines, but released them only shortly before, thus building
up quite a reputation ;-). So I ended up getting paid quite handsomely for
learning a new language.

I still like C a lot better, aesthetically. Ever wondered why there isn't
an obfuscated C++ contest? ;-)

--Daniel
 
D

DHOLLINGSWORTH2

C++ is a superset of C.

I dont know why I feel that needs explination, but:

C is part of C++, C++ is C and the ++.

Why is package A and B better or worse than just package A?

Well with package A and B you get all of the stuff in package A and all of
the stuff in package B. But in package A, you don't get any B stuff.

Thats why package A and package B is better.

C++ has one major disadvantage, that is coupled with its major advantage.
Speed and size versus Power.

You can write more powerfull programs quicker with c++. And as a result, it
will be a bigger and slower programm than doing the same thing in C alone.
If you want to take the time, and I mean sometimes close to 5 times the
coding to do the same thing in C, go for it.

BUT, just becuase you are using C++ doesn't mean you can no longer put C
code in your program.
Use a healthy mixture of both to pull the Power, AND Performance out of
you're computer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top