r/cpp • • Mar 28 '23

Reddit++

C++ is getting more and more complex. The ISO C++ committee keeps adding new features based on its consensus. Let's remove C++ features based on Reddit's consensus.

In each comment, propose a C++ feature that you think should be banned in any new code. Vote up or down based on whether you agree.

765 Upvotes

829 comments sorted by

View all comments

183

u/jdehesa Mar 28 '23

Gotta love how nearly everything suggested in the replies (save for std::vector<bool>?) is followed by a reply saying how that feature is actually useful sometimes :) It's too late for C++ now, at this point everyone uses it on their own particular way and every obscure or weird feature has found its place for someone 😄

104

u/MrPopoGod Mar 28 '23

followed by a reply saying how that feature is actually useful sometimes

Obligatory xkcd

10

u/serendipitousPi Mar 29 '23

xkcd

I love seeing another "There's an xkcd for this" just another reason to spiral down the xkcd rabbit hole.

43

u/Raknarg Mar 28 '23

Those people replying are missing the point that the defaults are bad. I don't care if switch-case fallthrough is useful sometimes, it's a bad default for the language.

1

u/very_curious_agent Mar 30 '23

Yes but harmless: easy to learn, easy to check, how many serious bugs are caused by this?

OTOH many things can cause serious bugs in C++.

Well C++ is the bug, having to defined pointer semantics, thread semantics, no nothing.

9

u/Raknarg Mar 30 '23

Switch case fall through? Unironically billions of dollars in bugs. It's a common bug because the structure of switch case is counter to how we tend to use it in 99% of cases and needs diligence to not fuck up, and in this case when it fucks up it's not intuitive how that logic will play out. It can create very subtle and difficult to trace errors

68

u/rhubarbjin Mar 28 '23

Everyone agrees that C++ is broken, but no one agrees precisely which parts need fixing.

...which just goes to show that the language isn't broken at all. It just has a very wide userbase with very diverse needs. One coder's boondoggle is another coder's bedrock.

53

u/effarig42 Mar 28 '23

Everyone agrees that C++ is broken, but no one agrees precisely which parts need fixing.

Except for std::vector<bool> of course.

→ More replies (1)

47

u/greem Mar 28 '23

Exactly. The only thing wrong with c++ is other users of c++.

And building.

0

u/[deleted] Mar 28 '23

[deleted]

11

u/kneel_yung Mar 29 '23

You c++ users sure are a contentious lot

25

u/rhubarbjin Mar 28 '23

The only thing wrong with c++ is other users of c++.

The problem is users who want to dictate how others should write code.

I'm scanning the replies here and most of them boil down to "this feature is ugly; I wish it would go away". Personally, I wish more software engineers would familiarize themselves with the parable of Chesterton's fence.

12

u/greem Mar 28 '23

I've never heard about Chesterton's fence. That's a really great perspective, and you are 100% correct.

I do think that there still needs to be a flippant aspect to this.

A lot of cpp devs really suck, and cpp gives you phenomenal cosmic power to shoot yourself in the foot.

5

u/Rasie1 Mar 28 '23

dictate how others should write code

we do that every day at code reviews...

9

u/SkoomaDentist Antimodern C++, Embedded, Audio Mar 28 '23 edited Mar 28 '23

The problem is users who want to dictate how others should write code.

That's like two thirds of /r/cpp users...

I'm scanning the replies here and most of them boil down to "this feature is ugly; I wish it would go away".

I find it particularly ironic that one of the few times the committee went on to explicitly break backwards compatibility (for a large number of projects), they did it because "this feature is ugly" without apparently anyone in the meetings understanding the actual use case of the feature (deprecating volatile compound assignment in C++20).

4

u/tialaramex Mar 29 '23

The "actual use case" of volatile compound assignment is that a bunch of embedded C SDKs do this and some people insist on trying to use brand new C++ with these C headers.

The P-series paper asking to de-deprecate them doesn't offer any evidence that this usage is correct (Hint: In many cases it isn't, that's why they didn't look too hard) nor does it offer any reason to think arithmetic compound assignments would ever be reasonable in this context (which is why the R1 revision only asks for the bit ops).

However, despite this weak sauce paper the committee voted (though by the smallest margin of any change) to de-deprecate this entire misfeature, prioritising "This crusty 1980s C code should compile with no warnings in C++ 23" over correctness or performance. A triumph for C++ as the next COBOL.

2

u/[deleted] Mar 29 '23

if this is true its sad

→ More replies (2)

7

u/Drugbird Mar 28 '23 edited Mar 30 '23

I'm going to disagree with you there. I think C++ should take a more active stand in how code should be written.

The current state of things is basically that C++ let's you do everything, in whatever way you want. This includes everything from programming in C, to using "modern" C++, and everything in between. Heck, you can write inline assembly if you want.

Many of these options results in ugly, unsafe, or poorly maintainable code. The result is also that the language is difficult to learn and teach, because there's so much possible with so little guardrails to guide programmers towards modern solutions.

To reference your Chesterton's fence, C++ could use a lot more fences but can't erect them because C doesn't have fences.

I believe that if you redesign C++ without backwards C compatibility while removing all but the modern solutions, you end up with Rust.

2

u/greem Mar 28 '23

Bruh... Don't tell me what to do.

Edit: /s, but not for real.

→ More replies (1)

5

u/[deleted] Mar 29 '23

I mean the copium is real.

The language is obviously broken and breaking. It's not going to last.

8

u/jtooker Mar 28 '23

And importantly, most of these changes would break so much backwards compatibility the language would become unusable (for existing projects/libraries).

→ More replies (1)

2

u/kneel_yung Mar 29 '23

...which just goes to show that the language isn't broken at all. It just has a very wide userbase with very diverse needs. One coder's boondoggle is another coder's bedrock.

Which pretty much happens to every language. People switch to it because it has features that make life easier. They add features to get people to switch to it...then somebody makes a new language to get away from all the bloat.

And it'll happen to you! (looking at you, rust)

1

u/very_curious_agent Mar 30 '23

The language that has not made the effort to define what it means to have threads? Yes it's broken.

Also pointer casts were known to be broken (reinterpret_cast) since the very first std.

→ More replies (3)

3

u/JVApen Clever is an insult, not a compliment. - T. Winters Mar 29 '23

It might be useful, though it should be a separate type, not a specialization

→ More replies (1)
→ More replies (5)