Newbie: The C / C++ Issue

Scott W wegster at
Tue Nov 11 19:06:01 PST 2003

Alex Kelly wrote:

>Thanks for all of the great suggestions to my previous question!
>Yet, the responses have led me to another question. If C++ is newer and more advanced than C, will it replace C? If so, should I learn C++ and forget C?
Again, it depends on WHAT you'd like to program.  That isn't to say you 
CAN'T program a specific type of application in language X, but some 
languages lend themselves to different tasks better.

C++ was supposed to 'replace C' since the 80s or so.  It's become more 
predominant for applications than C in _most_ cases, but the core OS of 
*bsd, Solaris, HP-UX, AIX, etc etc are all C.  Device drivers are 
written in C.  A large number of system daemons/services are written in 
C.  And yeah, because C lets you 'do as you want,' there are also some 
buggy C programs out there ;-) 

C++ may be a bit much if it's your first programming language.  There 
are things in CC++ that are ambiguous, moreso than in C- like the number 
of possible uses for the keyword 'const' among others (&$^#*&), and STL 
can be a _handful_ if you've never learned how to 'roll your own' data 
structures.  C pointers are at the same time a wonderful thing and a 
PITA to deal with at times.  C++ is generally MUCH fmore suited to GUI 
programming, and a few other tasks...but:

If you learn C first, and become competent at it, when/if you move on to 
another language, you'll have a better understanding of what's going on 
even if the 'next language' hides significantly more from you and makes 
your life easer (less coding, more use of libraries, foundation classes, 
STL, etc).

It's also not a terrible thing to learn C, and then ease into C++ simply 
as a 'better C'- stronger type checking, warnings that are now errors, 
and if pointers freaked you out TOO badly in C, you can then breathe a 
sign of relief and 'cheat' and use some of the functionality of C++ like 

If you DO go that route (C first), it's likely you'll be a better 
programmer in the end, seriously- starting with C++ can be like trying 
to run before you realize you have feet, and can result in 'knowing' 
C++, but writing code that no one in their right mind wants to touch.. 
starting in Java is akin to someone being shown how to fly, but not 
knowing how to land, or turn, or much else ;-)  Possibly not the best 
phrasing, but I've met MANY programmers that are very good at one 
specific thing, but put them even slightly out of their element (like 
umm, take Java away from them and make them use a 'real' language!) and 
they're extremely confused- mention POSIX system calls and they go blank...

The best thing I can suggest, which I do myself when I try to _force_ 
myself to get Java more solidly into my skillset, is to first learn 'a 
bit.'  Go through one of the recommended books (and BTW, whoever said 
Eckel's TIC++, yep, good call, missed that one although it's on all of 
my systems HDs :-)  and DO the excercises.  Pace yourself, especially 
while learning, and don't think 'you know that already' and skip over 
excercises and questions, no matter how inane some of them may seem ;-)  
Then, pick a 'real' project you'd like to do, starting reasonably small, 
maybe a small part of a larger project...or pick up Steven's APUE and 
write a talk daemon and client or something'll find 
things that you thought you knew that you realize you have no idea 
about.  One of the niceties of *nix are the man pages- if you're looking 
for a specific function (in the standard C library or system calls), try:

man -k <subject> where <subject> is a single word, like:
man -k open

will return a LOT of summaries of man pages with their headers including 
the word 'open.'  man man or man intro to get info on limiting them 
further, but you'll find youself using man pages a LOT while you go 
through your project, whatever it is.  Complete the first one, whatever 
it is, and then pick up the next book, then go a bit more ambitious, and 
use what you've got so far along with what should now be more 
'reference' books than 'teaching books' and keep going....use the force, 
Luke ;-)

Ok, I'll shaddup now... Did you catch the subtle hint in there to start 
with C? ;-)


More information about the freebsd-questions mailing list