Talk:C++

This is an old revision of this page, as edited by Deryck Chan (talk | contribs) at 04:25, 16 March 2006 (Move back to [[C++]]?). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Latest comment: 19 years ago by Deryck Chan in topic Move back to C++?
WikiProject iconC/C++ Unassessed
WikiProject iconThis article is within the scope of WikiProject C/C++, a collaborative effort to improve the coverage of C and C++ topics on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
???This article has not yet received a rating on Wikipedia's content assessment scale.
???This article has not yet received a rating on the importance scale.

Archives

#include <ostream>, #include <istream>, and all that...

According to the standard, operator << and operator >> for ostream and istream are declared in the headers <ostream> and <istream>. <iostream> is not required to include those headers. To be strictly conformant, the code examples using stream input and output have to include not only <iostream> but <ostream> and <istream> as well. --Tobias Bergemann 09:19, 14 October 2005 (UTC)Reply

You may be correct, but why do all books, including Bjarne's, use iostream? --MarSch 15:28, 27 October 2005 (UTC)Reply
Certainly not all books. "Accelerated C++" doesn't, if I remember correctly. But this really is a very minor point, and I won't revert if anybody changes the code examples again.
The header iostream has to include the definition of class std::ostream in some way, but the streaming operators are free functions, i.e. they are not part of the class definition. The class definition of class std::ostream may well reside in a separate header file that is included from both ostream and iostream but this separate header file need not include the declarations for the streaming operators. (Strictly speaking, iostream and ostream don't even have to exist as real files. The language standard is carefully worded so that the phrase #include <iostream> in the source has the effect to make available a certain set of classes, functions, and objects. It doesn't have to really include a source file.) --Tobias Bergemann 08:17, 28 October 2005 (UTC)Reply
Do you have a reference for your statement about the headers? --MarSch 13:14, 28 October 2005 (UTC)Reply
The ultimate reference is, of course, the standard document itself. My copy is at my workplace, so I can't quote chapter and verse until monday. Other than the standard I can only refer you to a couple of usenet discussions, e.g. "Standard hello world problem" and "Defect: std::endl in (a) 22.2.8/5, (b) 22.2.8/11, (c) 22.2.8/13, (d) 27.6.1.3/22" from comp.std.c++ and "templates" from comp.lang.c++.moderated.
In any case, most participants of the referenced usenet discussions (which included members of the standardization committee) apparently consider the current situation a defect in the standard that may well be fixed with the next revision. --Tobias Bergemann 20:06, 28 October 2005 (UTC)Reply
Ah, I found a post by Bjarne Stroustrup himself to alt.comp.lang.learn.c-c++ about the problem. --Tobias Bergemann 20:16, 28 October 2005 (UTC)Reply
I removed it again, and would like to see it stay that way. If it does not work for you, then you need a different compiler :)MadCow257 21:08, 3 March 2006 (UTC)Reply
Nevertheless, a compiler could perfectly implement the entire C++ standard and still require you to include ostream, thus it should stay in the article until this defect in the standard is corrected. --Yamla 21:23, 3 March 2006 (UTC)Reply

Cleanup

Wikipedia is not a repository of links. This article is extraordinarily long and full of links, of which some are certainly not appropriate (it has crossed the Spam Event Horizon). Please pare down the links to only what is appropriate for an encyclopedia. --bmills 14:45, 16 February 2006 (UTC)Reply

I decided to start being harsh with links. In particular I killed anything I felt was a) out of date, b) just links to things that look a bit like C++, but aren't or c) more suitable for the wikibook on learning C++.

As I expected, some things popped back in. http://www.eventhelix.com/RealtimeMantra/basics/ComparingCPPAndCPerformance.htm I would like to re-remove, but I'd perfer to talk about it. It claims to show how C++ maps to C. The problem is that the standard doesn't define how "C++ maps to C" so this ends up just being one person's belief on how they might go about implementing a C++ compiler. I know at least that the way is laying out functions bares little resemblance to how g++ goes about compiling C++ code, so I'm not convinced it is helpful.

I like your progress so far with the cleanup; you're definitely moving things in the right direction. As for the "mapping" link, have a look at this diff. That particular link was added as part of a pair from an anonymous DirecPC IP; checking other contribs from that IP reveals similar links at Session Initiation Protocol. I'd say that means it's linkspam, and thus safe to remove; if a comparison with implementation in another language is needed, we can always add actual content from a source that isn't out to make a profit. --bmills 18:34, 20 February 2006 (UTC)Reply
Cleaned a few references, it just looks like a huge list of books. --vineeth 07:24, 27 February 2006 (UTC)Reply

Tags

I removed 5 links and 7 see alsos as a part of the cleanup, and have now at least scanned the content of each remaining link and seen that it is reputable and worthwhile. With that in mind, my question is should the cleanup tags be removed? In my opinion, the one on the see also section should, and maybe link one too. I'm new to wikipedia editing so I don't know how that really works yets. MadCow257 23:58, 24 February 2006 (UTC)Reply

I've removed the cleanup tag from the "see also" section — it looks good! Still a lot of external links, but good progress is being made. I added a cleanup tag to the references, too, because it seems like some of those books are just C++ tutorials added for commercial and/or fanatical purposes, and you guys are doing such great work getting rid of cruft in the other sections! --bmills 02:46, 25 February 2006 (UTC)Reply

Standard Libraries

I recently replaced:

A project known as STLPort, based on the SGI STL, maintains an up-to-date implementation of the STL, IOStreams and strings. Other projects also make variant custom implementations of the standard library with various design goals.

with:

All C++ compilers provide an implementation of the C++ standard library. Compiler-independant implemenations, such as STLPort, also exist. Other projects also make variant custom implementations of the standard library with various design goals.

It was reverted by Ozzmosis as "inaccurate and unfinished". OK, I can see an argument the language could do with a little polishing, but I don't see that it was inaccurate. I don't know of any C++ compiler that doesn't ship with an implementation of the standard library, and I find for the most recent version of every compiler, their version is usually better than STLPort's. I feel the current wording implies STLPort is worthy as a "better implementation", whereas libstdc++ (g++'s implementation) or Dinkumware's (the verson packaged with vc++ and icc) are considered better by many people. Anyone want to suggest different / alternative wording? Mrjeff 11:11, 27 February 2006 (UTC)Reply

The problem with asserting that "all C++ compilers provide" is that you really don't know this for certain. It's possible for someone to write a C++ compiler that doesn't provide any standard libraries, eg. for an embedded system. Also, OpenWatcom C++ is one compiler that comes to mind that has only recently provided a very basic and incomplete STL implementation. See http://www.openwatcom.org/index.php/Open_Watcom_STL . The "unfinished" comment was my mistake as you left out a colon before the list and I misread the diff. --ozzmosis 12:44, 27 February 2006 (UTC)Reply
Ah, you think you've used most of the C++ compilers under the sun, and up pops another one :) I'll re-think how I'm going to change that section, and have another go :)
Why not just replace "all" with the weaker "many"? Presumably you can cite a fair number of compilers with STL implementations, and just about anything you could say has less POV than an STLPort ad. —donhalcon 14:56, 27 February 2006 (UTC)Reply
:-) Watcom C++ is pretty old now. Anyway, I've copyedited that paragraph so hopefully it's now a bit more accurate and unbiased. I used "most"! --ozzmosis 15:57, 27 February 2006 (UTC)Reply

A move and/or cleanup

Per the peer edit and the preferable article size policy, something needs to be moved out. I propose that a new article bad made called Syntax of C++. This would significantly reduce the size and technicality of this article, while giving more space for the rest of it too expand if needed. Thoughts? MadCow257 03:31, 5 March 2006 (UTC)Reply

The article has a lot of excess content; the "references" and "external links" sections could still use some trimming. Most of the "sample code" examples are also significantly longer they really need to be; the "polymorphism" section is very confusing (the basic idea gets across, but the details are muddled), so it might be good to clean that up and trim it down. Just some ideas for keeping the article size under conrol. —donhalcon 05:04, 5 March 2006 (UTC)Reply
MadCow257, I don't think moving the whole Syntax section out would be the right thing to do, because the Syntax section isn't really a section on Syntax at all; as it is now, every single section inside Syntax is not about syntax. Instead, I propose that "Sample Code" be moved into C++ examples (with a link to C++ examples remaining as the only thing in the "Sample Code" section) and that the "Syntax" header be deleted entirely until there is some section of the article that's really about C++ syntax, rather than sections that are about features of C++ which happen to show examples of syntax. --Tifego 02:28, 11 March 2006 (UTC)Reply
I went ahead and reorganized the article a little bit, but I didn't move anything out yet so it's still too big. The sample code should probably be moved or drastically shortened. And the section on Polymorphism really needs work. It has a big chunk of example code that is confusing and could be replaced with a couple of sentences, it tries to cover too many topics at once, has no clear focus, etc. Also, it only mentions templates sort-of in the passing, but they are a very important part of polymorphism in C++ and at least deserve their own subsection to emphasize that. --Tifego 03:34, 11 March 2006 (UTC)Reply
I would suggest the name C++ syntax for the child article, along the same lines as C syntax and Java syntax. – Doug Bell talkcontrib 12:13, 12 March 2006 (UTC)Reply

The move from "C++" to "C++ programming language"

I (mildly) oppose the recent move of the article from C++ to C++ programming language. From Wikipedia:Naming conventions (languages):

Languages which share their names with some other thing should be suffixed with "language" in the case of natural languages or "programming language" in the case of programming languages. If the language's name is unique, there is no need for any suffix.

However, the convention also states (using VBScript as an example of a language name where no disambiguation is needed):

Similarly, please place a redirect to VBScript at VBScript programming language and also at VBScript (programming language).

It is no big deal either way, and I won't revert the move. —Tobias Bergemann 10:16, 12 March 2006 (UTC)Reply

I agree - see Fortran, PHP, and Smalltalk for other examples of languages that don't end in "programming language". The move's only justification was that it was for consistency, but it's not consistent by those naming conventions. --Tifego 11:20, 12 March 2006 (UTC)Reply

I moved the article in this case for consistency with the other programming languages named after a letter. I don't know if the comparison to Fortran, PHP, and Smalltalk is an apples-to-apples comparison because the name C++ is, well, not much of a name by itself. Since Stroustrup himself calls it the "C++ programming language" (and named his book the same), I think the argument can also be made that that is the actual name of the language. However, if there is a strong consensus to change the name back, I'm not going to lose sleep over it. – Doug Bell talkcontrib 12:13, 12 March 2006 (UTC)Reply

If the scope of this encyclopedia were limited to computer programming related things, I would say the title "C++" is better than "C++ programming language". But it isn't. So, despite me finding the latter a bit clumsy, I think the longer title is true and correct. I took a look at the current ISO Standard. Its name is "Programming languages — C++" (ISO/IEC 14882, second edition 2003-10-15). The first sentence in the intro of the standard reads "This International Standard specifies requirements for implementations of the C++ programming language." I think the situation as it is now is perfect (article name = "C++ programming language" and a redirect to that under the name "C++). --Adrian Buehlmann 18:48, 12 March 2006 (UTC)Reply

OK, I'm convinced, although this means sort-of ignoring the Wikipedia:Naming conventions (languages). --Tifego 04:02, 13 March 2006 (UTC)Reply

However, C++ is a more commonly known and widely used name when compared to C++ programming language. Similarly, PHP is not at "PHP: Hypertext Preprocessor" and RuBisCO is not at Ribulose-1,5-bisphosphate carboxylase/oxygenase, because the naming convention says that the most widely used name should be adopted. C programming language and Pascal programming language etc. have the words "programming language" appended to the article name only because the omission of them creates ambiguity - simply "Pascal" can refer to the person Blaise Pascal, and simply "C" would make others think you're talking about the letter. But C++ cannot mean anything else - it MUST mean this programming language. Therefore I strongly propose a moveback. --Deryck C. 09:02, 13 March 2006 (UTC)Reply

Needs cleanup

I think this article is waaaaay too big for Wikipedia. All those "syntax", "operator" etc. stuff can be done away with. Section 7 -- the whole thing -- is IMO not Wikipedaic. We should link to tutorials, not write one ourselves. People come here to <learn about> C++, not to <learn> C++. If everyone agrees, someone should step up and do some *major* cleanup.

I removed the STL code examples; I don't really think we need them. Loads of programmers I know don't even use the STL. Jafet.vixle 03:44, 13 March 2006 (UTC)Reply

Looks like a step in the right direction. Everything after and including the "Incompatibility with C" section in this article is still way too long, though (as you said). I believe everything that's in the "Language features" section (and a few things that aren't) deserve an entry there for being very relevant to C++, but each subsection should either be much shorter, or consist of a link to another article that covers the topic in more detail. "Sample code" has a lot of description in it, someone should decide how much of that is really notable information. The section on Input/output streams in particular looks like a waste of space considering that io streams were already used in an example above that. --Tifego 03:59, 13 March 2006 (UTC)Reply

Also, this talk page is getting way too large, somebody should archive all but the newest few topics. --Tifego 04:05, 13 March 2006 (UTC)Reply

I moved discussions older than about january 2006 to /Archive 1. —Tobias Bergemann 13:46, 13 March 2006 (UTC)Reply

Move back to C++?

Previously Doug Bell moved this article from C++ to C++ programming language (see discussion above), and there was a dispute concerning his act with no conclusion drawn. I would like to propose a moveback of this article to C++, because:

  1. C++ is a more commonly known and widely used name when compared to C++ programming language. Similarly, PHP is not at "PHP: Hypertext Preprocessor" and RuBisCO is not at Ribulose-1,5-bisphosphate carboxylase/oxygenase, because the naming convention says that the most widely used name should be adopted.
  2. C programming language and Pascal programming language etc. have the words "programming language" appended to the article name only because the omission of them creates ambiguity - simply "Pascal" can refer to the person Blaise Pascal, and simply "C" would make others think you're talking about the letter. But C++ cannot mean anything else - it MUST mean this programming language.
  3. Wikipedia: Naming conventions (languages) reads Languages which share their names with some other thing should be suffixed with "language" in the case of natural languages or "programming language" in the case of programming languages. If the language's name is unique, there is no need for any suffix. We should conform to these rules.

--Deryck C. 04:56, 15 March 2006 (UTC)Reply

I agree with you Deryck, except for one thing. "C" is very commmonly used with "programming langauge", even among experienced coders. I've never heard anyone call C++ "C++ programming langauge" in my life. Point is C is not only called c programming because of ambiguity, but because that's its name. The same does not apply to C++ and it should remain C++. Not really a big issue though with the cheapness of redirects... MadCow257 23:30, 15 March 2006 (UTC)Reply
Just curious, but did you look at the previous discussion above regard "ever hearing it called "C++ programming langauge"? – Doug Bell talkcontrib 01:07, 16 March 2006 (UTC)Reply
Yes, I have, and there is more opposition then support there. I do realize that Wikipedia is not a democracy though. These kind of issues are small and numerous, the best policy would just be to leave them alone (why not make the major issues better first), so it was pretty disappointing when I saw it get moved to c++ programming language. As for Bjarne's book, let me make an analogy. C++ Programming Langauge :: Direct3D Graphics Programming. You would most likely not have a book called C++, nor a book called Direct3D. The longer version is not the name of the langauge, but the name + a description MadCow257 03:10, 16 March 2006 (UTC)Reply
And you never call this place "Wikipedia the free encyclopedia". If no more oppositions I think undoing the move is what I'd do. --Deryck C. 04:25, 16 March 2006 (UTC)Reply