This is the
talk page for discussing improvements to the
Criticism of C++ article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google ( books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
Archives: 1 |
This article is rated C-class on Wikipedia's
content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||||||
|
This article links to one or more target anchors that no longer exist.
Please help fix the broken anchors. You can remove this template after fixing the problems. |
Reporting errors |
The history of this article is really odd. It seems like User:Rincewind82 was working on a personal user-land criticisms page, and then a completely different user decided to move it into this page. This seems rather dubious to me. User Rincewind82 has contributed to exactly two pages: this one and a few things with Lean software development. Whereas Anthony is a well-established user. But his contributions rarely stray into technology. I'm curious about what happened here. Did Rincewind82 ask Anthony to move this page, or did Anthony do that on his own? And if it's the latter, why? Korval ( talk) 17:14, 26 January 2016 (UTC)
Hi, the article was written by me. I first made it in my sandbox not to disturb anyone. Later I was unable to move the article for some reason. Probably because of a redirect already being there. I then made a request to move the article on Requested_moves/Technical_requests. I hope this was ok? I'm new on Wikipedia and I'm not yet used to the procedures here. Rincewind82 ( talk) 19:08, 26 January 2016 (UTC)
In the example code function POSIX_Poll, is there a reason why fdopen(fd.fd, "r") is used instead of just File? Also, mixed case variable names are discouraged by the kernel coding standard. Michael9422 ( talk) 22:00, 24 May 2016 (UTC)
User:Michael9422 Hi Michael! No, there is no reason. I only wanted to show how to convert between descriptors and file structs. Feel free to change the example regarding this and the formatting. Rincewind82 ( talk) 18:37, 25 May 2016 (UTC)
I saw this example given as a critique of the "C++ type-safety" claims. Can someone explain to me why this program compiles without errors or warnings, despite not using a cast?
class A { public: int a;};
class B : public A { public: int b;} barray5];
A *aarray = barray;
int main()
{
aarray4].a = 5;
}
Michael9422 ( talk) 04:39, 27 May 2016 (UTC)
A *aarray = barray;
barray
of type B[5]
"decays" into a pointer to a B
(namely the address of the array's first element), and C++ explicitly allows assignment from a pointer to the derived class B
to a pointer to B
's base class A
. Now, in the lineaarray4].a = 5;
aarray[4]
is
syntactic sugar for *(aarray + 4)
(
pointer arithmetic). Evaluating this expression when aarray
points to the first element of barray is
undefined behavior because aarray
does not point into an array of A
s. The compiler, however, is not required to detect this violation of the language rules (and in fact in general cannot detect violations of this language rule), trusting the author of that code that he know what he's doing. –
Tea2min (
talk)
12:42, 27 May 2016 (UTC)[]
that's already undefined. And it's not an example of the programmer explicitly requesting a violation of the type system (as I understand that phrase), it's undefined behavior (as opposed to implementation-defined behavior or unspecified behavior). The compiler is explicitly allowed to assume that aarray
in the expression *(aarray + 4)
points to an element of a big enough array of A
s, no questions asked. The compiler is not required (and generally not able) to detect violations of this precondition of pointer arithmetic.static_cast
or a const_cast
or, more explicity, a reinterpret_cast
. The mapping performed by reinterpret_cast
for example is implementation-defined, and the C++ standard explicitly lists the legal applications of reinterpret_cast
. This includes for example converting a pointer to any integral type large enough to hold it and back. –
Tea2min (
talk)
07:26, 9 June 2016 (UTC)struct A { int a;};
struct B { struct A a; int b;} barray5];
struct A *aarray = barray;
int main()
{
aarray4].a = 5;
}
barray
decays to a pointer to the first element of that array, that is, to a pointer to an instance of struct B
, and the language rules forbid assigning such a pointer to a pointer to an A
. Instances of derived classes are related in the sense that every instance of class B
in the first code example above is-a A
, and that's the reason the language rules allow the assignment of a pointer to a B
to a pointer to an A
. This relation does not hold for instances of struct B
and instances of struct A
in the second code example. An instance of struct B
contains an instance of struct A
but it is not true that an instance of struct B
is-a instance of struct A
. –
Tea2min (
talk)
17:48, 9 June 2016 (UTC)I think that the article could use a section called 'complexity'. A frequent criticism is that the language is too complicated (from, for example, programmers Ken Thompson and Eric Raymond; or Thomas Becker's blog article "C++ and the culture of complexity"). That results in more time and effort for developers to become proficient compared to simpler languages, and is exacerbated by the many unexpected language pitfalls, or hidden "gotchas". The complexity also makes it harder to read and understand code written by others, which can, for example, reduce productivity for software projects with many contributors. Also, the higher level, abstract features that C++ adds to C, tend to break the tight correspondence C has to machine code (Linus Torvalds says it "[breaks] the mental model", or something to that effect), making those features undesirable and probably counterproductive for systems level programming (this is also expressed by Martin Sustrik regarding ZeroMQ). Michael9422 ( talk) 19:25, 8 June 2016 (UTC)
What do other editors think? Michael9422 ( talk) 20:14, 8 June 2016 (UTC)
There are other people too who have said that the complexity of the language is a problem. Besides Ken Thompson, several of the programmers interviewed in the book "Coders at Work" make that claim (their quotes are in the link to excerpts from the book in the External Links section). Bjarne Stroustrup has said "Within C++ there is a much smaller and cleaner language struggling to get out" and "I’m convinced that you could design a language about a tenth of the size of C++ (whichever way you measure size) providing roughly what C++ does..." Michael9422 ( talk) 16:24, 1 September 2016 (UTC)
I will also point out that most, if not all, of the foreign language wikipedia articles about C++ that have a criticism section include a mention of excessive complexity, at least judging by google's translation. Michael9422 ( talk) 18:17, 22 June 2017 (UTC)
I think the problem with a section on complexity, is that it's a pretty difficult thing to quantify in objective terms that are suitable for Wikipedia. A good starting point may be feature orthogonality. Eg. how constructors may only fail via exceptions (and the flexibility implications of this, the ZeroMQ author talked about this), how the semantics of C++03 complicated the design of move semantics, how template specializations interacted with the design of concepts etc. There seems to be a trend here: overly eager adoption of potentially flawed designs. 79.114.11.51 ( talk) 08:50, 23 June 2019 (UTC)
I recently added some external links to this article (too many actually) that were subsequently removed by other editors. I do not intend to restore them, but I want to point out that there are quite a few other articles, about software at least, that have external links to blogs or humorous articles that do not meet the same wikipedia guidelines given as the reason for removing the links that I added. For example, see the wikipedia article 'Programming productivity'. Should those links be removed? Michael9422 ( talk) 16:12, 12 June 2016 (UTC)
There's no point in the criticism that std::string
does not support unicode, being a sequence of bytes. Thus, it's basically encoding agnostic.
Furthermore, the point about length()
is of no value: Requiring the function to return the number of code points is nothing more than a special case (why not "grapheme clusters" or "user perceived characters"?), and does not make any sense with unspecified encoding. In fact (and talking about Unicode and a specific encoding), when interfacing with other software components, the length in bytes is what's needed often enough.
See [1] for further arguments on the topic.
As a result, I'd like to have the "Strings without Unicode" section deleted. Alternatively, I'd suggest to add the arguments above to adhere to the "Neutral point of view" principle.
mkluwe ( talk) 19:44, 22 November 2016 (UTC)
How is it that a laundry list of complaints and criticism of C++ was assembled reaching several pages, but no one wrote anything about undefined behavior? Or the "strict aliasing rule" and the difficulty of diagnosing such problems in real code bases? Or the "static initialization fiasco"? Or the lack of a common ABI and the difficulties of distributing C++ programs to multiple platforms, and the plethora of different packaging systems for each operating system for obtaining the dependencies? Speaking as someone who uses C++ regularly, many of the most severe difficulties of using C++ are not mentioned, and many of the things given a lot of space in the article are comparatively trivial in practice.
IMO the article needs attention from an expert. Many of the categories are not actually criticism of the C++ language, but rather of the C++ standard library -- global format state of iostream, heap allocations in containers, iterators...
I like C++, but there's no doubt that there's a lot of crap in the foundations, which threatens the security and performance of real systems in the wild, and creates a lot of problems and headaches for software engineers. That kind of discussion is probably worthy of wikipedia. A lot of the stuff that is mentioned in this article comes off as "pet peeves" rather than serious criticism.
96.81.51.113 ( talk) 22:52, 7 February 2017 (UTC)
I agree with the original point. The article hits some very specific criticisms, but is missing big picture things like UB and Complexity. Maybe a small step would be to rework the Iterator section as a UB section. The problems it lists with Iterators seem to be more UB. Quimn ( talk) 00:01, 3 May 2020 (UTC)
This source
<ref>{{Cite web|url=http://gameangst.com/?p=226|title=Minimizing Code Bloat: Template Overspecialization|author=Adrian Stone}}</ref>
that I had added previously was removed recently from the section named 'code bloat', but I think it is appropriate. What do other editors think? Michael9422 ( talk) 19:25, 13 March 2017 (UTC)
I feel the whole section is obsolete since std::array...?!? -- DevSolar2 ( talk) 11:54, 26 October 2017 (UTC)
I agree, removed. Quimn ( talk) 01:59, 2 May 2020 (UTC)
C++'s awfully complicated grammar should be discussed, and how that makes parsing it slow. 213.149.61.212 ( talk) 20:17, 9 November 2017 (UTC)
<
and >
, parsing being undecidable and who knows what else).
Maëlan
15:14, 4 May 2024 (UTC)In the lead, a quote by the creator of C++ reads as so:
"There are only two kinds of languages: the ones people complain about and the ones nobody uses."
What's the significance of it? What's the point? It doesn't seem notable nor relevant enough to warrant its position. It rather looks like someone inserted it to display Bjarne Stroustrup as dismissive with criticism of C++. KlayLay ( talk) 01:50, 8 August 2021 (UTC)
I fixed the citation, this is chapter 10 of a book tilted The Unix Haters Group. I disagree in general with that book, I like Unix, but I can agree with what it say about C++, lets be fair, E.W.Dijkstra said something alike about OOP, but I am just going to fix the title of the book.
This whole entry lacks any sort of cohesion as there is no logical connection between different sections; it's not clear why these poorly collections of mini-rants are compiled into an encyclopedia entry. This whole page, from top to bottom, reads like a poor attempt at gluing together a bunch of random early 2000s blog post-style rants written by a frustrated, mediocre programmer venting off to divert attention from his own mediocrity. There is a pretty good "Criticism" section under the main C++ entry that gives you more information than the entirety of the "C++ Criticism" entry.
So I just have to ask: What is the point of this? Why is this so disorganized? And why does this read like a blog post?! 139.68.209.96 ( talk) 01:48, 22 November 2023 (UTC)
This is the
talk page for discussing improvements to the
Criticism of C++ article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google ( books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
Archives: 1 |
This article is rated C-class on Wikipedia's
content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||||||
|
This article links to one or more target anchors that no longer exist.
Please help fix the broken anchors. You can remove this template after fixing the problems. |
Reporting errors |
The history of this article is really odd. It seems like User:Rincewind82 was working on a personal user-land criticisms page, and then a completely different user decided to move it into this page. This seems rather dubious to me. User Rincewind82 has contributed to exactly two pages: this one and a few things with Lean software development. Whereas Anthony is a well-established user. But his contributions rarely stray into technology. I'm curious about what happened here. Did Rincewind82 ask Anthony to move this page, or did Anthony do that on his own? And if it's the latter, why? Korval ( talk) 17:14, 26 January 2016 (UTC)
Hi, the article was written by me. I first made it in my sandbox not to disturb anyone. Later I was unable to move the article for some reason. Probably because of a redirect already being there. I then made a request to move the article on Requested_moves/Technical_requests. I hope this was ok? I'm new on Wikipedia and I'm not yet used to the procedures here. Rincewind82 ( talk) 19:08, 26 January 2016 (UTC)
In the example code function POSIX_Poll, is there a reason why fdopen(fd.fd, "r") is used instead of just File? Also, mixed case variable names are discouraged by the kernel coding standard. Michael9422 ( talk) 22:00, 24 May 2016 (UTC)
User:Michael9422 Hi Michael! No, there is no reason. I only wanted to show how to convert between descriptors and file structs. Feel free to change the example regarding this and the formatting. Rincewind82 ( talk) 18:37, 25 May 2016 (UTC)
I saw this example given as a critique of the "C++ type-safety" claims. Can someone explain to me why this program compiles without errors or warnings, despite not using a cast?
class A { public: int a;};
class B : public A { public: int b;} barray5];
A *aarray = barray;
int main()
{
aarray4].a = 5;
}
Michael9422 ( talk) 04:39, 27 May 2016 (UTC)
A *aarray = barray;
barray
of type B[5]
"decays" into a pointer to a B
(namely the address of the array's first element), and C++ explicitly allows assignment from a pointer to the derived class B
to a pointer to B
's base class A
. Now, in the lineaarray4].a = 5;
aarray[4]
is
syntactic sugar for *(aarray + 4)
(
pointer arithmetic). Evaluating this expression when aarray
points to the first element of barray is
undefined behavior because aarray
does not point into an array of A
s. The compiler, however, is not required to detect this violation of the language rules (and in fact in general cannot detect violations of this language rule), trusting the author of that code that he know what he's doing. –
Tea2min (
talk)
12:42, 27 May 2016 (UTC)[]
that's already undefined. And it's not an example of the programmer explicitly requesting a violation of the type system (as I understand that phrase), it's undefined behavior (as opposed to implementation-defined behavior or unspecified behavior). The compiler is explicitly allowed to assume that aarray
in the expression *(aarray + 4)
points to an element of a big enough array of A
s, no questions asked. The compiler is not required (and generally not able) to detect violations of this precondition of pointer arithmetic.static_cast
or a const_cast
or, more explicity, a reinterpret_cast
. The mapping performed by reinterpret_cast
for example is implementation-defined, and the C++ standard explicitly lists the legal applications of reinterpret_cast
. This includes for example converting a pointer to any integral type large enough to hold it and back. –
Tea2min (
talk)
07:26, 9 June 2016 (UTC)struct A { int a;};
struct B { struct A a; int b;} barray5];
struct A *aarray = barray;
int main()
{
aarray4].a = 5;
}
barray
decays to a pointer to the first element of that array, that is, to a pointer to an instance of struct B
, and the language rules forbid assigning such a pointer to a pointer to an A
. Instances of derived classes are related in the sense that every instance of class B
in the first code example above is-a A
, and that's the reason the language rules allow the assignment of a pointer to a B
to a pointer to an A
. This relation does not hold for instances of struct B
and instances of struct A
in the second code example. An instance of struct B
contains an instance of struct A
but it is not true that an instance of struct B
is-a instance of struct A
. –
Tea2min (
talk)
17:48, 9 June 2016 (UTC)I think that the article could use a section called 'complexity'. A frequent criticism is that the language is too complicated (from, for example, programmers Ken Thompson and Eric Raymond; or Thomas Becker's blog article "C++ and the culture of complexity"). That results in more time and effort for developers to become proficient compared to simpler languages, and is exacerbated by the many unexpected language pitfalls, or hidden "gotchas". The complexity also makes it harder to read and understand code written by others, which can, for example, reduce productivity for software projects with many contributors. Also, the higher level, abstract features that C++ adds to C, tend to break the tight correspondence C has to machine code (Linus Torvalds says it "[breaks] the mental model", or something to that effect), making those features undesirable and probably counterproductive for systems level programming (this is also expressed by Martin Sustrik regarding ZeroMQ). Michael9422 ( talk) 19:25, 8 June 2016 (UTC)
What do other editors think? Michael9422 ( talk) 20:14, 8 June 2016 (UTC)
There are other people too who have said that the complexity of the language is a problem. Besides Ken Thompson, several of the programmers interviewed in the book "Coders at Work" make that claim (their quotes are in the link to excerpts from the book in the External Links section). Bjarne Stroustrup has said "Within C++ there is a much smaller and cleaner language struggling to get out" and "I’m convinced that you could design a language about a tenth of the size of C++ (whichever way you measure size) providing roughly what C++ does..." Michael9422 ( talk) 16:24, 1 September 2016 (UTC)
I will also point out that most, if not all, of the foreign language wikipedia articles about C++ that have a criticism section include a mention of excessive complexity, at least judging by google's translation. Michael9422 ( talk) 18:17, 22 June 2017 (UTC)
I think the problem with a section on complexity, is that it's a pretty difficult thing to quantify in objective terms that are suitable for Wikipedia. A good starting point may be feature orthogonality. Eg. how constructors may only fail via exceptions (and the flexibility implications of this, the ZeroMQ author talked about this), how the semantics of C++03 complicated the design of move semantics, how template specializations interacted with the design of concepts etc. There seems to be a trend here: overly eager adoption of potentially flawed designs. 79.114.11.51 ( talk) 08:50, 23 June 2019 (UTC)
I recently added some external links to this article (too many actually) that were subsequently removed by other editors. I do not intend to restore them, but I want to point out that there are quite a few other articles, about software at least, that have external links to blogs or humorous articles that do not meet the same wikipedia guidelines given as the reason for removing the links that I added. For example, see the wikipedia article 'Programming productivity'. Should those links be removed? Michael9422 ( talk) 16:12, 12 June 2016 (UTC)
There's no point in the criticism that std::string
does not support unicode, being a sequence of bytes. Thus, it's basically encoding agnostic.
Furthermore, the point about length()
is of no value: Requiring the function to return the number of code points is nothing more than a special case (why not "grapheme clusters" or "user perceived characters"?), and does not make any sense with unspecified encoding. In fact (and talking about Unicode and a specific encoding), when interfacing with other software components, the length in bytes is what's needed often enough.
See [1] for further arguments on the topic.
As a result, I'd like to have the "Strings without Unicode" section deleted. Alternatively, I'd suggest to add the arguments above to adhere to the "Neutral point of view" principle.
mkluwe ( talk) 19:44, 22 November 2016 (UTC)
How is it that a laundry list of complaints and criticism of C++ was assembled reaching several pages, but no one wrote anything about undefined behavior? Or the "strict aliasing rule" and the difficulty of diagnosing such problems in real code bases? Or the "static initialization fiasco"? Or the lack of a common ABI and the difficulties of distributing C++ programs to multiple platforms, and the plethora of different packaging systems for each operating system for obtaining the dependencies? Speaking as someone who uses C++ regularly, many of the most severe difficulties of using C++ are not mentioned, and many of the things given a lot of space in the article are comparatively trivial in practice.
IMO the article needs attention from an expert. Many of the categories are not actually criticism of the C++ language, but rather of the C++ standard library -- global format state of iostream, heap allocations in containers, iterators...
I like C++, but there's no doubt that there's a lot of crap in the foundations, which threatens the security and performance of real systems in the wild, and creates a lot of problems and headaches for software engineers. That kind of discussion is probably worthy of wikipedia. A lot of the stuff that is mentioned in this article comes off as "pet peeves" rather than serious criticism.
96.81.51.113 ( talk) 22:52, 7 February 2017 (UTC)
I agree with the original point. The article hits some very specific criticisms, but is missing big picture things like UB and Complexity. Maybe a small step would be to rework the Iterator section as a UB section. The problems it lists with Iterators seem to be more UB. Quimn ( talk) 00:01, 3 May 2020 (UTC)
This source
<ref>{{Cite web|url=http://gameangst.com/?p=226|title=Minimizing Code Bloat: Template Overspecialization|author=Adrian Stone}}</ref>
that I had added previously was removed recently from the section named 'code bloat', but I think it is appropriate. What do other editors think? Michael9422 ( talk) 19:25, 13 March 2017 (UTC)
I feel the whole section is obsolete since std::array...?!? -- DevSolar2 ( talk) 11:54, 26 October 2017 (UTC)
I agree, removed. Quimn ( talk) 01:59, 2 May 2020 (UTC)
C++'s awfully complicated grammar should be discussed, and how that makes parsing it slow. 213.149.61.212 ( talk) 20:17, 9 November 2017 (UTC)
<
and >
, parsing being undecidable and who knows what else).
Maëlan
15:14, 4 May 2024 (UTC)In the lead, a quote by the creator of C++ reads as so:
"There are only two kinds of languages: the ones people complain about and the ones nobody uses."
What's the significance of it? What's the point? It doesn't seem notable nor relevant enough to warrant its position. It rather looks like someone inserted it to display Bjarne Stroustrup as dismissive with criticism of C++. KlayLay ( talk) 01:50, 8 August 2021 (UTC)
I fixed the citation, this is chapter 10 of a book tilted The Unix Haters Group. I disagree in general with that book, I like Unix, but I can agree with what it say about C++, lets be fair, E.W.Dijkstra said something alike about OOP, but I am just going to fix the title of the book.
This whole entry lacks any sort of cohesion as there is no logical connection between different sections; it's not clear why these poorly collections of mini-rants are compiled into an encyclopedia entry. This whole page, from top to bottom, reads like a poor attempt at gluing together a bunch of random early 2000s blog post-style rants written by a frustrated, mediocre programmer venting off to divert attention from his own mediocrity. There is a pretty good "Criticism" section under the main C++ entry that gives you more information than the entirety of the "C++ Criticism" entry.
So I just have to ask: What is the point of this? Why is this so disorganized? And why does this read like a blog post?! 139.68.209.96 ( talk) 01:48, 22 November 2023 (UTC)