Important alert: (current site time 7/15/2013 6:42:06 PM EDT)
 

article

Should I learn C before C++? Isn't C better because it has less overhead?

Email
Submitted on: 6/27/2000 10:36:06 AM
By: Blake Madden 
Level: Beginner
User Rating: By 12 Users
Compatibility: C++ (general)
Views: 15078
(About the author)
 
     Offers advice on whether you must know C before C++ and whether C is preferable over C++ because of overhead.

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
				Should I learn C before C++? Isn't C better because it has less overhead?
These are very valid questions and ones that I believe should be answered prior to delving into the world of C/C++. I feel that the answers are "no, you should learn C++ first, then you should come to understand the fundamental differences C++ and its predocessor" and "no, C++ still retains the efficiency of C with improved and new features." Many people are apt to veiw C and C++ as two entirely different languages, whereas I prefer to see C++ as an improved version of C that can still utilize many of the features that are thought of as "C-style." Some C programmers will argue that C++ is too large with too much overhead. The fact is that there is indeed more overhead with classes as opposed to (C-style, data-only) structures. However, you should bear in mind that just because you are using C++ you don't need to make everything object-oriented. This is to say, if you feel the situation calls for a simple structure or enumeration, then by all means use them. There's nothing wrong with utilizing the less complex and more efficient C-style data types when data encapsulation isn't a major concern, but memory is. The point is, C++ is a better C with improved (completely overhauled , actually) data structures, memory allocation, and I/O features. You are much better off learning and using this improved methods first, and then go back and familiarize yourself with the way C handles these methods. C++ is a big, complex language, but I honestly don't feel that coming to learn C first will necessarily aid you. Learning C's (error-prone) I/O system and memory allocation instead of C++'s will only cause bad practice and style further down the road. However, you should at least understand C's methods in case you ever work with legacy code. You also can familiarize yourself with the data structure efficieny in C, so that you can incorproate that along with object-oriented data structures. I have to agree with some C++ critics that it can have a bit of overhead in some cases, but C++'s advanced features--like overloaded operators and multiple inheritance--are options, not requirements. This is the whole reason why C was chosen to be the base language, because of its efficiency, and C++ still has all of that efficieny with improved and more features. 


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
6/28/2000 4:32:42 AMDustin Davis

Dude, dont post things like this on PSC. But if you must know, i learned C before C++ and C was easy to learn, C++ was hard, but knowing C made it alot easier. I suggest doing as I did, learn C basics, then learn C++.
(If this comment was disrespectful, please report it.)

 
6/28/2000 11:25:56 AMBlake Madden

What's easier?

C:

CObject* pObject = (CObject*)malloc(sizeof(CObject));

or C++:

CObject* pObject = new CObject;

C:

printf("Integer %i Float %f Pointer %p", IntVar, FloatVar, PointerVar);

or C++:

cout << IntVar << " " << FloatVar << " " << PointerVar;


Yes, I'll be the first to admit that classes are quite overwhelming (pure virtual destructors?, yikes!), but C++'s memory allocation and I/O makes both learning and usage of C/C++ so much easier. C++ (for the most part) handles a lot of the dirty work for you.
(If this comment was disrespectful, please report it.)

 
6/30/2000 3:38:53 PMEli

This is nice, but really does not belong to this site.
(If this comment was disrespectful, please report it.)

 
6/30/2000 3:52:46 PMBlake Madden

This is a C++ site isn't it? Anyway, this was the first question I had when I first looked at C++, and this was the same advice that I got from numerous others when I asked. Therefore, I am sharing that advice to others now. I thought the reason people come here is to find answers to his/her C/C++ questions.
(If this comment was disrespectful, please report it.)

 
7/14/2000 12:43:14 AMaramas@ace-net.com.au

Hey, I got a copy of a friends old MSVC4.1 compiler. I really want to learn C (already great at VB) and I have checked out a few tutorials and books, but is there a better way to lealrn? how did all you gusy learn C ?
(If this comment was disrespectful, please report it.)

 
8/4/2000 8:44:28 PMDan Corkery

Thanks Blake for advice on
(If this comment was disrespectful, please report it.)

 
8/4/2000 8:49:30 PMDan Corkery

...Don't know what happened there...my message didn't appear! Anyway,...all I said was that I found your advice good and, being a "Newbie" to programming(having never read a book yet), I think sites such as this should cater for both those who know and those who don't!
As I said..it's a shame they didn't teach this stuff to us when I was in school!
(If this comment was disrespectful, please report it.)

 
8/8/2000 9:46:36 AMandy

I dont how those guys can say this article is irrelevant or not to post it.. This is exactly what I was trying to determine and the consensus from all sources seems to be NOT to learn C first, unfortuneatly I have yet to come across a C whoa to go tutorial, most assume C knowledge. Thanks Blake.
(If this comment was disrespectful, please report it.)

 
8/29/2000 2:50:47 PMMike

I have to agree with Andy, Dan and Blake. This is exactly why I come to PSC, to answer my questions. I'm a VB programmer trying to learn C/C++, and the first thing I thought of was,
(If this comment was disrespectful, please report it.)

 
8/29/2000 2:53:46 PMmike

Dont know why that dropped out like that, what I said was....
the first thing I thought was HEY, PSC might have some general answers on how best to learn. This place is for coders of all levels, not just for those who don't know. Thanks Blake! I appreciate the knowledge you have shared with us all.
(If this comment was disrespectful, please report it.)

 
9/14/2000 9:37:05 PMAngelsMajestic

Just thought I'd add my 2 cents worth.
I've been learning VB and now want to
learn c/c++. Didn't even know there was
a difference between the two c's.
Call me dumbo, but I for one
am sure glad this was posted. Now I have
a somewhat better concept of this c thing.
And I think I'll try the ++ one first.
Thanks for considering us newbies..,

(If this comment was disrespectful, please report it.)

 
9/19/2000 10:46:02 AMmaster control

I learned C++ by reading The C++ programming lanaguage by Bjarne Stroustrup. This book starts the first couple of chapters on basics (like learning c with modifications) then jumps into the objects and polymorphism. If you know VB, you'll pick this book up quick. Greatest book ever. Oh yeah the author lead the development of C++. This article is an extremely important question.
(If this comment was disrespectful, please report it.)

 
10/20/2000 3:37:19 PMBen Jacobs

I disagree and think that you should learn C first. C programs take less time to compile, are smaller, and C is easier to learn. If you want to learn C the really easy way get Dan Gookin's "C for Dummies Volume 1." It starts out at an extremely basic and easy to understand level and works up, still explaining everything great.
(If this comment was disrespectful, please report it.)

 
10/23/2000 1:28:16 PMCheetah_Research

I just wanted to say thank you that it has been helpful for us newcomers to programming to wonder if C or C++ is the area to start, I was told C first before, but if you have an overall structural knowledge of logic, C++ I see now, should be no problem, thank you for considering and helping us confused newcomers in the field of programming, especially us hard working mothers, like me!
(If this comment was disrespectful, please report it.)

 
1/28/2001 10:42:52 PMRodolfo

Great post. Exactly what I was looking for! I'm a VB programmer, and I was wondering about: "what should I learn first?"... Now I realize that the best thing to do is to come from the highest level language (such as VB) and then to go to the lower ones, like C++, then C, then Assembly...
Thanks!
(If this comment was disrespectful, please report it.)

 
5/6/2004 8:56:55 AM

i learnt C before C++ and I laugh at anyone who says it should be the other way around. it would be like wanting to fly before learning how to walk.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.