r/cpp • • Nov 27 '20

The C++ 20 initialization flowchart

I've created a flowchart that shows all of C++20's initialization rules.

The source code is available at https://github.com/randomnetcat/cpp_initialization, in addition to the SVG version and PNG Version.

This honestly took a lot less time than I was expecting, and, in my humble-but-biased opinion, is relatively interesting.

Please send all complaints to /u/quicknir, who nerd-sniped me into making this.

116 Upvotes

34 comments sorted by

View all comments

Show parent comments

9

u/Frptwenty Nov 28 '20

Please don't do that. I argue with the "hurr durr C++ is broken use C and Rust" crowd there, and this will just make them even more hopeless.

19

u/Fureeish Nov 28 '20

They are half right. Many things are broken in the language and, trying to speak objectively, C and Rust have fewer broken elements compared to C++. Does that mean that they are strictly better? Obviously no.

16

u/Frptwenty Nov 28 '20

objectively, C and Rust have fewer broken elements compared to C++

It depends on what you're doing. Objectively speaking C++ is a miles better option than C in a huge amount of cases.

Imho the lack of easily usable basic strings, dynamic-sized containers etc. etc. are a huge broken feature of C. Other things you take for granted in C++ like RAII, smart pointers and templates are also a huge deal compared to C.

People like to claim they don't ever matter, but that's bullshit. Of course there are low-level cases where they don't, but the "only use C" crowd want to pretend it's a better alternative for big "regular" applications.

Rust, well... what's the point of arguing. It never ends.

7

u/Fureeish Nov 28 '20

That's why I added two last sentences to my comment.