Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Nov 2003 22:05:37 -0500
From:      Scott W <wegster@mindcore.net>
To:        Alex Kelly <alexkelly@adelphia.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Newbie: The C / C++ Issue
Message-ID:  <3FB1A381.9060903@mindcore.net>
In-Reply-To: <002c01c3a8c1$a4651bb0$6400a8c0@desktop>
References:  <002c01c3a8c1$a4651bb0$6400a8c0@desktop>

next in thread | previous in thread | raw e-mail | index | archive | help
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?
>
>Alex
>  
>
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 
references..

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 similar....you'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? ;-)

Scott



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3FB1A381.9060903>