Jump to content

Talk:C++/Archive 10

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by MiszaBot I (talk | contribs) at 02:13, 20 March 2010 (Archiving 2 thread(s) from Talk:C++.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Archive 5Archive 8Archive 9Archive 10Archive 11Archive 12

"Bloated" and "complicated"

I've found and added a nice reference for the existing wording in the article from a Niklaus Wirth's quote:

C++ is a language that was designed to cater to everybody’s perceived needs. As a result, the language and even more so its implementations have become monstrously complex and bulky, difficult to understand, and likely to contain errors for ever.[1]

However, the problem is that from the article text it appears as if Stroustrup refutes this:

I have even seen the C++ version of the 'hello world' program smaller than the C version.

However, he doesn't: Wirth - as well as most C++ critics, presumably - is talking about the language and its implementation, and not about the resulting executables. GregorB (talk) 01:07, 8 August 2009 (UTC)

The problem with this quote is that it is extremely subjective and inaccurate. Take the bit about errors: While bugs in e.g. gcc occasionally do surface, they seem no more common than what I see in many other language implementations, likewise I find writing C++ no more bulky than writing in many other languages, including such languages as Haskell or Java. Nor is the standard particularly long, if that is what is meant with bulky. Difficult to understand is, of course, a function of the user, and a lot of people seems to have few or no problems understanding C++. Mental faculties do wary, of course. As for the Stroustrup quote, there is a more pertinent quote right on the wiki page under the criticism. What annoys me about these criticism is that there is plenty of /valid/ criticism (e.g. the inclusion of the throws declarations, the heavily overloaded "static" keyword, or the way enums pollute the owning class), but apparently the critics would rather flung subjective mud :/ Esben (talk) 15:54, 7 November 2009 (UTC)

Do we need this retarded criticism page?

Did anyone read this? Im talking about this: [2]. This is full of bs, i checked the linked subpage, containing infos about references, and the writer totally doesnt know what hes talking about. Its ok to criticize C++ if you like, i have my own problems as well, but if youre plainly stupid than dont be linked to the Wikipedia. IMHO. 192.100.130.238 (talk) 07:54, 6 November 2009 (UTC)

I agree, just reading 8.2 makes you realize this. On the other hand, C++ seems to be a traumatic experience to many, and having these pages seems to let them vent some steam. Perhaps we could move the links to some ""hate sites" section? The linked page is obviously from someone who loves C... note how he cannot see the advantage of std::vector over C arrays. Esben (talk) 16:07, 7 November 2009 (UTC)

I don't know, there could be a section about this (though my english is not so perfect :(). My impression is that C++ is the language that created the most hate and love (in short: emotions) towards itself. The site in question is definitely one proof/reference for this. 84.2.161.52 (talk) 16:48, 8 November 2009 (UTC)

The FQA does not meet the external links guideline. There are several reasons for this.

  1. Sites that "misleads the reader by use of factually inaccurate material or unverifiable research" are to be avoided
  2. Personal web pages should be avoided, unless written by a recognized authority
  3. Sites that do not provide a unique resource beyond what the article would contain if it became a Featured article, should be avoided

decltype (talk) 19:05, 8 November 2009 (UTC)

I have re-added the FQA link twice now, and it's been deleted in short order both times. I'm going to desist because I have better things to do with my time, but it's disappointing to me to see that the WP C++ page become a hangout for C++ cheerleaders. WP should offer well-rounded (encyclopedic even) coverage of this topic, and part of doing that is pointing out major criticisms of the language. The FQA may be "just a web page", but pretty much every knowledgeable C++ programmer is familiar with this now-famous page. Even if (if!) this page is not 100% factual, this is hardly a bar to linking, as this is true for most of WP's other external links as well. Like it or not, C++ has some serious problems, people have taken note of this in public, and WP should not be trying to sweep these facts under the run. Mkcmkc (talk) 14:01, 29 November 2009 (UTC)

Supposedly edits are by consensus - you appear to be the only promoter of the content (aside from the page's author) Tedickey (talk) 15:21, 29 November 2009 (UTC)
I don't mind criticism of C++ --- there is plenty to criticize --- but that page is so full of errors it would not help anyone, except perhaps a C-fanboy who wants his ego stroked. But I'd applaud any factual criticism page. Esben (talk) 15:28, 29 November 2009 (UTC)

Stuff removed from Boolean data type article

The following section was removed from the article Boolean data type:
begin removed text



During its standardization process, the C++ programming language introduced the bool, true and false keywords, adding a native data type to support Boolean data. Its size is implementation-defined.[1] bool was introduced in 1993[2].

Values of type bool are either true or false.[3] Implicit conversions exist between bool and other integral types, floating point types, pointer types, and pointer-to-member types.[4] In addition, user-defined types can be converted to bool via a user-defined conversion operator. In general, a zero or null-pointer value is converted to false, any other value is converted to true.

#include <string>

int main()
{  
  using std::string; 
  // implicit conversions to bool
  bool a = 'a'; // char -> bool  [true]
  bool b = 0.0; // double -> bool  [false] 
  bool c = -1; // int -> bool  [true]
  bool d = 0; // int -> bool  [false]
  bool e = &a; // bool* -> bool  [true]
  bool f = &string::clear; // void (string::*)() -> bool  [true] 
   
  // implicit conversions from bool
  int i = false;    // bool -> int  [0]
  double j = true;  // bool -> double  [1.0]
  char* k = false; // bool -> char*  [(char*)(0)]   
}

The 1998 C++ Standard Library defines a specialization of the vector template for bool. The description of the class indicates that the implementation should pack the elements so that every bool only uses one bit of memory.[5] This is widely considered a mistake[6][7]. vector<bool> does not meet the requirements for a C++ Standard Library container. For instance, a container<T>::reference must be a true lvalue of type T. This is not the case with vector<bool>::reference, which is a proxy class convertible to bool.[8] Similarly, the vector<bool>::iterator does not yield a bool& when dereferenced. There is a general consensus among the C++ Standard Committee and the Library Working Group that vector<bool> should be deprecated and subsequently removed from the standard library, while the functionality will be reintroduced under a different name[9]. This change is unlikely to take place until after C++0x.


  1. ^ ISO/IEC (2003). ISO/IEC 14882:2003(E): Programming Languages - C++ §5.3.3 Sizeof [expr.sizeof] para. 1
  2. ^ "Evolving a language in and for the real world: C++ 1991-2006" (PDF). 2007. Retrieved March 2008. {{cite web}}: Check date values in: |accessdate= (help)
  3. ^ ISO/IEC (2003). ISO/IEC 14882:2003(E): Programming Languages - C++ §3.9.1 Fundamental types [basic.fundamental] para. 6
  4. ^ ISO/IEC (2003). ISO/IEC 14882:2003(E): Programming Languages - C++ §4.7 Integral conversions [conv.integral] para. 4
  5. ^ ISO/IEC (2003). ISO/IEC 14882:2003(E): Programming Languages - C++ §23.2.5 Class vector<bool> [lib.vector.bool] para. 1
  6. ^ "vector<bool>: More Problems, Better Solutions" (PDF). 1999. Retrieved May 2007. {{cite web}}: Check date values in: |accessdate= (help); Unknown parameter |month= ignored (help)
  7. ^ "A Specification to deprecate vector<bool>". 2007. Retrieved May 2007. {{cite web}}: Check date values in: |accessdate= (help); Unknown parameter |month= ignored (help)
  8. ^ ISO/IEC (2003). ISO/IEC 14882:2003(E): Programming Languages - C++ §23.2.5 Class vector<bool> [lib.vector.bool] para. 2
  9. ^ "96. Vector<bool> is not a container". Retrieved January 2009. {{cite web}}: Check date values in: |accessdate= (help)

end removed text
Is there a place for this text in the C++-related articles? Perhaps in the Wikibook? Thanks, and all the best, --Jorge Stolfi (talk) 23:27, 30 December 2009 (UTC)

The first two paragraphs are still adequately summarized in Boolean data type; the last should probably go into Vector (C++). —Korath (Talk) 23:37, 5 January 2010 (UTC)
I have incorporated the vector<bool> info into the vector article. No need to take extra steps for attribution after the merge, since I wrote it all. decltype (talk) 07:08, 6 January 2010 (UTC)

Hello World!

I think the example listed is absolutely fucking retarded, why bother listing such a tedious method, may I suggest:

#include <iosteam>
using namespace std;
{
  cout << "Hello World!" << endl;
}
It's not gonna get changed, because, to stop unproductive edit-warring, we've chosen to stick with the "official" version from the language's designer, which is at least not arbitrary. (see hidden HTML comment in the Hello World section for more info). --Cybercobra (talk) 00:34, 22 July 2009 (UTC)
Your suggested example doesn't even compile. Stroustroup's version does. -- Autopilot (talk) 13:02, 23 July 2009 (UTC)

Tombrown16 (talk) 22:37, 17 January 2010 (UTC) I think my addition was fine, It shows the conventional C++ Hello World program allowing windows users to pause to see the output text, I have not deleted the example hello world I have merely added a more conventional one. I have also added a note about the windows only feature, you have no reason to delete it! There is nothing wrong with:

#include <iostream>
using namespace std;
int main()
{
   cout << "Hello World " << endl;
   system("PAUSE");
   return 0;
}

—Preceding unsigned comment added by Tombrown16 (talkcontribs) 22:35, 17 January 2010 (UTC)

An introductory example in an article about a programming language is not the place to show how to work around a specific operating system's misfeatures. Especially since your example doesn't compile without including stdlib.h and relies on an external program rather than something portable like getchar(). —Korath (Talk) 22:54, 17 January 2010 (UTC)

Tombrown16 (talk) 23:06, 17 January 2010 (UTC) Okay I agree with you to some extent :) But I still think showing this under the given example would be better.

#include <iostream>
using namespace std;
int main()
{
   cout << "Hello World " << endl;
   return 0;
}
This has been discussed at length on the talk page archive and consensus was (eventually) reached. The reasons for the current version are that it is sourced to the author of the language and his book on C++. It does have some idiosyncrasies, such as eliding the return 0 and using "\n" rather than std::endl, but it remains the canonical Hello, World by the author of C++. There is no reason to include two hello world examples in the page (WP:NOTHOWTO). -- Autopilot (talk) 17:50, 18 January 2010 (UTC)

Improved Hello World

The C++ Hello World example is pitiful, it demonstrates bad programming practice by classifying the namespace instead of importing it, Also /n is non portable and endl is the standard way of doing things. This is the example I propose.

#include <iostream>
using namespace std;

int main()
{
   cout << "Hello, world!" << endl;
   return 0;
}

This is a way better example and should be shown replacing the current example or underneath it as a second example the current example is poor! Tombrown16 (talk) 17:50, 18 January 2010 (UTC)

'\n' (not /n) is just as portable as std::endl since for text mode files it will output the appropriate platform specific line ending as per the standard. Importing the entirety of namespace std is frowned upon by several style guides, such as this C++ FAQ. Again, this topic has been discussed ad naseum in the archives of this talk page. -- Autopilot (talk) 18:51, 18 January 2010 (UTC)
Given the myriad possible variants of Hello World to choose from, the choice is essentially arbitrary, but at least using the one from the language designer's own book is minimally arbitrary. --Cybercobra (talk) 20:31, 18 January 2010 (UTC)

I propose a C++ control flow example anyone agree? Tombrown16 (talk) 18:11, 18 January 2010 (UTC)