The cplusplus.com tutorial (on-line) and other resources.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This message turned into a bigger listing than I originally intended. I guess I should put to gether a web page of C++ resources I like. This may have been posted before, but it seems worth calling people's attention to again. List membership changes over time, and sometimes things like this are forgotten. I haven't read all the tutorial, but it is the kind of thing that I should have read at the beginning of my C++ ordeal...uh I mean to say learning effort. http://www.cplusplus.com/doc/tutorial/index.html I know I posted this title before. It's along the same lines, and is what I actually used as a 'jump start'. _Essentials of C++_ http://www.booksmatter.com/b0878917489.htm Another short and sweet treatment of some aspects of C++ is: C++ Notes: Table of Contents http://www.fredosaurus.com/notes-cpp/index.html Also worth mentioning is: C++ GUI Programming with Qt 3 by Jasmin Blanchette and Mark Summerfield "This is the first official Qt book, written by two veteran Trolls. The book is now available in US bookstores and from online booksellers." http://www.trolltech.com/ It's taken me about 100 pages to adjust to the presentation style. But if you just understand that they treat code listings as paragraphs, and they always present the code, and then describe it, usually with very little prior introduction, the text will probably read smoothly for you. I guess it's a sign that I am learning the C++ language when I look at a page full of code and feel relieved that I will almost certainly get through it fastart than a page of prose. STH -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQFAOXXoH2SF0i7rrGwRAtF8AJ9dupck/oeh+bUwJHiAT9mN+ndhiwCgtdTP 5RhzpomuTQx92+R3WPcs2Co= =X6JQ -----END PGP SIGNATURE-----
At the risk of starting a flame war (please, no flames on this excellent
list!)...
Does anyone know if there are good technical reasons why C was used to
program the Linux kernel rather than C++ or one of the more modern OO
languages? Surely the reuse inherent in OO would improve solid reuse and so
shorten testing times as OO does when used well elsewhere in the programming
world?
I have often heard people imply that C is more powerful for writing faster
code as it allows more low-level features like register directives, etc. but
that seems an unlikely reason not to use C++. Further, many places (e.g.
the tty code I have been studying) seem to make extensive use of structures,
with most work on those structures being done by passing a pointer to the
structure to a procedure/function as the first parameter - the
procedure/function then does the work (modifying the structure data,
creating a new structure, destroying and freeing memory, etc.) - this is
very much like a method call, yet not perfectly formalised so that the
encapsulation, inheritance and polymorphism are slightly patchy (although
the "line discipline" code there looks very much like virtual methods).
The only thing I can think of is that extensive reuse might, in the end, be
worse than rewriting core functionality so that it would be all too easy to
get into "don't ever touch that object, it's core, and tested thoroughly -
instead derive from it", the performance implications being obvious. Maybe
sometimes constant "breaking" of core areas to upgrade them to perfection is
"a good thing"?
I am probably being naive, please forgive me if so! I do not mean to offend
anyone at all, I am just very new to the Linux kernel and Linux programming
in general and rather curious about these things.
Regards,
Carl Peto
----- Original Message -----
From: "Steven T. Hatton"
On Mon, 23 Feb 2004 09:02:53 -0000
"Carl Peto"
Does anyone know if there are good technical reasons why C was used to program the Linux kernel rather than C++ or one of the more modern OO languages? Surely the reuse inherent in OO would improve
I think the main reason was that at that time gcc C++ was not production ready... or C++ as a whole was not production ready. Anyway if you google it I bet you'll find some official answer... the FAQ of linux-kernel mailing list has some http://www.tux.org/lkml/#s15-3
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 23 February 2004 04:22 am, Ivan Sergio Borgonovo wrote:
On Mon, 23 Feb 2004 09:02:53 -0000
"Carl Peto"
wrote: Does anyone know if there are good technical reasons why C was used to program the Linux kernel rather than C++ or one of the more modern OO languages? Surely the reuse inherent in OO would improve
I think the main reason was that at that time gcc C++ was not production ready... or C++ as a whole was not production ready.
Why do you speak in the past tense? ;-) Sorry. I'm just a bit disappointed with a few aspects of C++. No doubt it represents a very significant advance in many ways. There are, however, a few places where the design was seriously encumbered by what I believe to have been unnecessary concerns about C compatability. There are a few (many) places where Stroustrup seems to be a bit frustrated with the restrictions placed on C++ by the 'C compatability extremists'. There are also, IMO, too many 'conveniences' built in. That is, slick ways of accomplishing things that really aren't that difficult to accomplish in more pedestrian ways. I'm not that experienced with the language, but I have the sense that some of these features may actually increase the amount of work expended in a the lifecycle of a project. If every moderately experienced programmer is sent flipping through the pages of his favorite C++ book to understand some arcane expression, the intended convenience is lost. I find the division of header and implementation to cause programs to be hard to follow. One feature I would like to seen in KDevelop (I believe I actually submitted this as a wishlist item) is the ability to view both the implementation and header in the same frame. I wish more C++ programmers understood the advantages that some Java features and practices provide. It may simply be my lack of experience, but for me, locating comperable information in a C++ development environment is more difficult and time consumming than in a similar Java environment. As I've suggested, some of that is simply practice. The same types of things can be accomplished with C++. It's just not part of the culture. I was wondering if a new version of C++ could be introduced which would address some of it's shortcomings. An example of the kind of thing that bothers me about C++ is discussed on page 244 of Stroustrup's TC++PL 3rd Ed, SE. "The reason for the dissimilar treatment of classes and built-in types are C compatibility and fear of run-time overhead." I read that as: 'If I had my way, it wouldn't be so fubar'.
Anyway if you google it I bet you'll find some official answer... the FAQ of linux-kernel mailing list has some http://www.tux.org/lkml/#s15-3
"Should the kernel use object-oriented programming techniques? Actually, it already does. The VFS (Virtual Filesystem Switch) is a prime example of object-oriented programming techniques. There are objects with public and private data, methods and inheritance. This just happens to be written in C. Another example of object-oriented programming is Xt (the X Intrinsics Toolkit), also written in C. What's important about object-oriented programming is the techniques, not the languages used. " This is an important point. You *can*, and people *do* write OO code in C. You *can* and people *do* write non-OO code in C++. I am of the opinion that C++ is not an 'object oriented' programming language. It is an 'object inclined' programming language. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQFAOeliH2SF0i7rrGwRAq6nAJ9SYNfEH5FIW7YWuMBKZcmE/asTowCghEgg Xbbrqb/eCheYz+gAvFbu8UA= =imiK -----END PGP SIGNATURE-----
On Mon, 23 Feb 2004 06:51:56 -0500
"Steven T. Hatton"
I think the main reason was that at that time gcc C++ was not production ready... or C++ as a whole was not production ready.
Why do you speak in the past tense? ;-) Sorry. I'm just a bit
Do you prefer Java? ;) Try to ask to Linus to rewrite the kernel in Java ;)
disappointed with a few aspects of C++. No doubt it represents a
Agree... at least considering gcc support and in general libraries, some "modern" concepts of programming (threads, parallel computing, interface with OS, network) and as pointed out in the linux-kernel ml FAQ exceptions can be a PITA in some environment. There has been a lot of improvement on this side anyway, but I can't still forecast any improvement for adoption of good libraries to interfac
There are also, IMO, too many 'conveniences' built in. That is, slick ways of accomplishing things that really aren't that difficult to accomplish in more pedestrian ways. I'm not that experienced with the language, but I have the sense that some of these features may actually increase the amount of work expended in a the lifecycle of a project. If every moderately experienced programmer is sent flipping through the pages of his favorite C++ book to understand some arcane expression, the intended convenience is lost.
Disagree. I think in all these cases your freedom of choice is preserved.
frame. I wish more C++ programmers understood the advantages that some Java features and practices provide. It may simply be my lack
Those features comes at a cost and in Java you have not "freedom of choice".
of experience, but for me, locating comperable information in a C++ development environment is more difficult and time consumming than in a similar Java environment.
Guess why. Standardizing a language is a war. Many compromises have to be reached.
I was wondering if a new version of C++ could be introduced which would address some of it's shortcomings. An example of the kind of thing that bothers me about C++ is discussed on page 244 of Stroustrup's TC++PL 3rd Ed, SE. "The reason for the dissimilar treatment of classes and built-in types are C compatibility and fear of run-time overhead." I read that as: 'If I had my way, it wouldn't be so fubar'.
LOL... maybe.
This is an important point. You *can*, and people *do* write OO code in C. You *can* and people *do* write non-OO code in C++. I am of the opinion that C++ is not an 'object oriented' programming language. It is an 'object inclined' programming language.
C++ is a tool, a tool that helps writing OOP more than C. And you can shoot at yourself in the foot with a lot of different tools. OK... rumbling finished ;)
On Mon, 23 Feb 2004 06:51:56 -0500
"Steven T. Hatton"
wrote: I think the main reason was that at that time gcc C++ was not production ready... or C++ as a whole was not production ready.
Why do you speak in the past tense? ;-) Sorry. I'm just a bit
Do you prefer Java? ;) Try to ask to Linus to rewrite the kernel in Java ;) I haven't looked at the gcc Java compiler, but, if I'm not mistaken, it will
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This thread has taken an unexpected direction, so I decided to change the subject header. On Monday 23 February 2004 07:51 am, Ivan Sergio Borgonovo wrote: produce (non-portable) native executable binaries. Don't laugh too hard at the idea of doing such a thing in Java. I am sure it won't be called the Linux kernel, and I don't believe it is all that likely to see an OS kernel written in Java. OTOH, I recall a discussion a few years back about running the KDE on Windows NT. People were telling the guy who suggested it was possible that he didn't know what he was talking about. I said it was possible in theory, but unlikely in practice, well: http://kde-cygwin.sourceforge.net/kde3/screenshots.php Java has some very nice features/aspects that C++ lacks. Some of these could be addressed if a standard abstraction layer api were adopted by a large enough community of developers. When I say "abstraction layer api", I mean to distinguish this form abstraction layer implementation. An example of an abstraction layer implementation is the Netscape Portable Runtime http://www.mozilla.org/projects/nspr/. This might serve as a precedent for establishing such an api, but the api I'm suggesting would be a specification from 'above'. IOW, as long as it supported the applications' requests for system resources, it would be a valid implementation. I'm not sure how POSIX fits into such a picture.
frame. I wish more C++ programmers understood the advantages that some Java features and practices provide. It may simply be my lack
Those features comes at a cost and in Java you have not "freedom of choice". Here's a good example of how C++ can be more difficult to deal with than Java, and also a good example where standardization could improve the situation. The Xerces-J doesn't cause any issues that I am aware of regarding strings, and how they are implemented. I am currently working on a Qt project that uses XML. I was considering using Xerces, rather than the QDOM support in Qt. But translating Xerces string representation to and from QString is going to require some effort. This is the API documentation for Xerces XMLString class:
http://xml.apache.org/xerces-c/apiDocs/classXMLString.html
of experience, but for me, locating comperable information in a C++ development environment is more difficult and time consumming than in a similar Java environment.
Guess why. Standardizing a language is a war. Many compromises have to be reached.
I believe another reason is simply perspective and attitude. C++ coders are accustomed to that kind of environment, and just assume learing to work with C++ means learing to navigate your way through an unfamiliar maze of header files and libraries. Java was designed to avoid a lot of those problems, but, to a large extent, the Java community believes such obscurity should be avoided, and mechanisims for automating the location of resources are a high priority. I own a copy of MS Visual C++, but the idea of working in XP for a long enough time to learn to use it is too distasteful to consider seriously. I suspect, however, it and Borland's C++ Builder both provide a lot of the kinds of support I'm talking about.
C++ is a tool, a tool that helps writing OOP more than C. And you can shoot at yourself in the foot with a lot of different tools.
I had a professor who compared C and C++ coding with sword dancing on ice. If you're good at it, it's quite impressive, but if your not, you're likely to hurt yourself. STH -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQFAOhNLH2SF0i7rrGwRApMTAJ4iE/xI2C96f2CFwEXmFtJvWol+HQCgwkXC zHaMlbTbxlD0Eb8EYqlrrMI= =1fXF -----END PGP SIGNATURE-----
On Mon, 23 Feb 2004 09:02:53 -0000 "Carl Peto"
wrote: Does anyone know if there are good technical reasons why C was used to program the Linux kernel rather than C++ or one of the more modern OO languages? Surely the reuse inherent in OO would improve
I think the main reason was that at that time gcc C++ was not production ready... or C++ as a whole was not production ready.
Anyway if you google it I bet you'll find some official answer... the FAQ of linux-kernel mailing list has some http://www.tux.org/lkml/#s15-3 I was going to respond, but all I would be doing would be to paraphrase
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Mon, 23 Feb 2004 10:22:18 +0100
Ivan Sergio Borgonovo
On 23 Feb 2004 at 9:02, Carl Peto wrote:
From: "Carl Peto"
At the risk of starting a flame war (please, no flames on this excellent list!)...
Does anyone know if there are good technical reasons why C was used to program the Linux kernel rather than C++ or one of the more modern OO languages? Surely the reuse inherent in OO would improve solid reuse and so shorten testing times as OO does when used well elsewhere in the programming world?
Stop right there before you start a religious war! There are many reasons why people prefer different languages, not only because of the facilities that the languages offer, but because some languages fit that person's mindset better than others. I've programmed for many years in both C and C++, and I've also programmed in Fortran IV, Forth, Pascal, Delphi, a little Python and even Basic. I prefer C++, because I think it's more expressive and less error prone, but I see nothing wrong in programming in C or any other language. Good progamming transcend the specific language you are using - I've seen spaghetti code programmed in Pascal. Far important than arguing about what language, is to learn programming skills - how to design programs, data structures and algorithms. Once you have that skill you can choose the most appropriate language and pick up its essentials relatively rapidly. alan -- http://www.ibgames.net/alan Registered Linux user #6822 http://counter.li.org Winding Down - Weekly Tech Newsletter - subscribe at http://www.ibgames.net/alan/winding/mailing.html
participants (5)
-
alan@ibgames.com
-
Carl Peto
-
Ivan Sergio Borgonovo
-
Jerry Feldman
-
Steven T. Hatton