Another Newbie Question: C or C++
freebsd at keyslapper.org
Tue Nov 11 05:54:38 PST 2003
On 11/10/03 07:12 PM, Scott W sat at the `puter and typed:
> Alex Kelly wrote:
> >I need to buy a book on C or C++ to help me in FreeBSD. Which would be better to buy?
> >I first thought a book on C would be best, because the OS is written in C. But, now I'm not sure because I read that gcc can compile C++ too (so, I'm assuming C++ must get used too).
> >Does it even matter?
> >freebsd-questions at freebsd.org mailing list
> >To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
> It depends on your goals. I used to teach both C and C++, and now years
> later, am currently hard pressed to find a non-Microsoft C/C++
> development position. If for personal knowledge, definitely C followed
> by C++. If professional, or want to be....hmm. In that case, I'd say
> it still depends more on your goals- if you're going to try to stay in
> *nix development, you've GOT to know C. If you don't care, or God help
> you, want a job doing Windows development, start with C++, and ignore
> all of the standard data types because MS will make their own for you ;-)
> Starting with C has an advantage in that you tend to have to do 'most of
> the work yourself' for a lot of things, which tends to help you
> understand more about how things work. IMHO, that also tends to make
> better programmers down the line, regardless of the language they use.
> C++ is similar, but STL will make life easier when it comes to data
> structures. Java I don't want to talk about ;-)
> A significant amount of system level programming(think system processes
> and services/daemons) are written in C. A fair number of applications
> are, but the majority of GNOME/KDE apps, if that's a consideration, are
> done in C++. A growing number of applications are also being done in
> Java, but it's not the best language to start with for understanding
> much of anything (you can write a half dozen lines of Java to replace
> perhaps 100+ in C/C++ from scratch in some cases). It isn't a bad
> language to learn (professional-wise as well, *groan*) after learning C
> or C++.
> Books and references-
> C- Already mentioned, K&R 'The C Programming Language' is 'the bible.'
> This is also generally a lousy book to start with if you aren't
> programming already, but an invaluable reference. Pick up another book,
> wish I knew a good starter one, but it's been a while...can try Deitel
> and Deitel or (nobody laugh, have used it for Intro before..) the 21
> days SAMs series for a 'jump-start,' and THEN the Deitel/Deitel and K&R.
> W. Richard Stevens "Advanced Programming in the UNIX Environment"- MUST
> HAVE. I may be misquoting the name, but a search on bookpool.com ,
> bn.com (or search on amazon then BUY somewhere else!) will quickly turn
> it up. K&R is to the C language, Stevens is to Unix programming...
> google search for 'Secure Unix Programming'- there's a FAQ or two out
> there that are pretty good once you're past 'the basics.'
> Latest edition of Deitel/Deitel. Funny, I used to really dislike their
> books, but they DO provide pretty decent overall coverage. May or may
> not be 'too deep' at first, if so, preface with SAMs or equivalent.
> Stroustrup- 'The C++ Programming Language". Stroustrup write C++ but is
> pretty dry. Good reference and for advanced topics.
> Stroustrup- Annoted Reference Manual AKA 'the ARM'- what K&R is to C.
> *The C++ Standard Library : A Tutorial and Reference- recommended pretty
> highly, but don't currently have. search on favorite bookstore will
> turn it up.
> *Java (before ya ask ;-) There are a LOT of bad books on Java it
> seems. Deitel and Deitel again is worth buying as a first book (after C
> and/or C++), then decide what you want to DO with Java, as there are a
> number of directions- JDBC, Beans, JSP, etc etc etc..
> As always, languages and books can be a moving target- when possible,
> pick up the latest edition covering the current ANSI standard for C/C++,
> and make sure anything you buy for Java covers 'Java 2,' preferably JDK
> 1.4, but at least 1.3 or you'll be throwing out work by the time you
> work on a current project..
> Misc others-
> POSIX Programming, O'Reilly press. Good coverage of POSIX (Unix for
> simplicity's sake but not really) required system calls.
> Network Programming- Again,m by Stevens.
> FAQs for whatever you wind up taking an interest in. I don't _like_ GUI
> development, but KDE and GNOME have a fair number of tutorials for QT
> and GTK respectively...
Wow, that's a fairly complete list. Agree completely on the C/C++
application/philosophical differences. The book list missed one very
useful C++ book by Josutis, "The C++ Standard" I think. Don't have it
You know, everyone's been telling me to give up C and just start
working with C++. I've been resisting pretty strongly, and now I
realize why. C is a geeks language. It gives you more control than
C++. I like C for one primary reason: I like to be in control. I
know that many of the C++ constructs, member functions, etc. are slow
in comparison to home grown vanilla construct in C that only do what
they are needed for. The standard template classes use table lookups
just to figure out what its contents look like. If you create the
construct from scratch, it knows whether it's holding an int, char*,
And the arguments about faster machines meaning that level of
efficiency is unimportant will fall on deaf ears here. Efficiency
should always be in the top 3 list (correctness, stability, and
efficiency are the trinity of the true programmer).
I'm gonna stop here because this is going to turn into a holy war
shortly, but take Scott's description of the applications,
availability, and books to heart. The only thing I can really add
(for all my babbling here) is the Josutis book for C++.
Louis LeBlanc leblanc at keyslapper.org
Fully Funded Hobbyist, KeySlapper Extrordinaire :)
Canada Bill Jones's Supplement:
A Smith and Wesson beats four aces.
More information about the freebsd-questions