At 07:51 PM 7/1/01 -0500, Jim Roland wrote:
>I don't know much about C++ and C, I'm just learning myself.  It's written
>in either C or C++, but it never hurts to write in C++, besides there are
>compilers (free) that work with C++.  The reason I suggested C++ is because
>those books are easier to find, at least for me.

First, the kernel (the "it" in Jim's second sentence) is written in C (with
some bits of inline assembly), not C++. No reason for confusion here; this
is not a judgment call. See comment 4 below for some of the "why".

Second, the original question was about reading the kernel source, not
writing; to read it, you have to learn the language it is written in, not
the one you prefer. C and C++ are similar, but they are different enough
that someone who *only* knows C++ will not be able to read C source very
successfully. I myself bounce back and forth between C and C++, and whenever
I first switch, I always make mistakes for a little while ... the obvious
ones, like new vs malloc, free vs delete, iostreams vs stdio, messy C
strings vs tidy C++ Strings. Stupid stuff, usually, but one develops habits ....

Third, the most commonly-used free compiler for Unix/Linux, gcc/g++,
compiles both languages just fine (C a wee bit better than C++ ... I think
still ... though I haven't done any C++ on Linux recently to be sure of this).

Fourth, the statement "it never hurts to write in C++" is just plain wrong.
Decisions between languages always involve tradoffs. While C++ has many
benefits (I use it a lot, mostly for my Windows applications-development
work), it also has some costs ... using C++ in the way it is intended almost
always involves taking a performance hit relative to C ... workarounds for
this do exist, but they involve a lot of handwork of the sort that C++ is
intended to make unneeded. Read the book _Efficient C++_ (Bulka and Mayhew,
I think ... my copy is at work, not here at home) to get a feel for some of
the performance problems with C++ and how to avoid or minimize them.

Fifth, there are good resources -- books and online stuff -- for learning
either language. Anyone with access to the Web (e.g., Amazon) should have no
trouble getting the good titles for either language.


--
------------------------------------"Never tell me the odds!"---
Ray Olszewski                                        -- Han Solo
Palo Alto, CA                                    [EMAIL PROTECTED]        
----------------------------------------------------------------

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.linux-learn.org/faqs

Reply via email to