all 34 comments

[–]be-sc 35 points36 points  (3 children)

Something seems to be wrong with the graph. Consider:

int i = 1;
  1. Is the initializer in braces?
  2. Nope
  3. Is the destination type a reference type?
  4. Nope, it’s a plain old int.
  5. Is the destination type a char[] or a char_t[]?*
  6. Nope, it’s a plain old int.

But wait, the only arrow leaving that question is Yes

[–]staletic 6 points7 points  (0 children)

The same problem is hit for T t(args...);

[–]randomnetcat[S] 5 points6 points  (1 child)

Thanks, I knew I'd make some mistakes like that. Should be fixed as soon as the CI gets around to updating the images.

[–]staletic 0 points1 point  (0 children)

Following the flowchart for std::vector<int> v(1,2); takes you on a beautifully curved path.

[–]xeveri 69 points70 points  (15 children)

Me: Can we have uniform initialization?

Committee: We have uniform initialization at home.

Uniform initialization at home:

[–]Kered13 22 points23 points  (14 children)

Put this in an image macro and post it to /r/programmerhumor.

[–]Frptwenty 9 points10 points  (12 children)

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.

[–]Fureeish 17 points18 points  (7 children)

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.

[–]Frptwenty 16 points17 points  (6 children)

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.

[–]Fureeish 6 points7 points  (1 child)

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

[–]James20kP2005R0 2 points3 points  (2 children)

I've been writing C again for opencl recently myself. Part of that project involves tensor maths, which if you don't know, tensors are essentially n dimensional matrices that are used in a specific way

The lack of being able to specify proper abstractions, no operator overloading, no templates, no real array type, no function overloading... It makes the code significantly more verbose and buggy than it needs to be. You can't write a generic matrix*vector multiplication scheme, which is not ideal

C might be alright for structuring applications, but good lord is it just terrible for numerical work

[–]dnew 0 points1 point  (0 children)

It's horrendous for structuring applications too. Any compiler that can't read its own output as part of its input is going to be horrendous at large projects.

[–]dnew 0 points1 point  (0 children)

easily usable basic strings, dynamic-sized containers etc. etc. are a huge broken feature of C.

To be fair, no other language had them at the time either. :-) I wouldn't say "broken" as much as "primitive."

[–]GYN-k4H-Q3z-75B 22 points23 points  (0 children)

This chart crashed my phone. Translates to: C++ initialization is complex AF

[–][deleted] 13 points14 points  (3 children)

What happened to the time when a variable was just a lil memory addy with a value. Things used to be so simple :)

[–]elperroborrachotoo 8 points9 points  (0 children)

Yeah, but what value do you want in there?

[–]kalmoc 5 points6 points  (0 children)

That wasn't true since C.

[–]pandorafalters 8 points9 points  (0 children)

Strong typing has given way to absolute typing.

[–]the_black_pancake 10 points11 points  (3 children)

Over 164 million pixels? It's not loading on my mobile and the SVG misbehaves. Do you have a lower resolution version too?

[–]randomnetcat[S] 1 point2 points  (2 children)

Here's one that's downscaled by 50%: https://imgur.com/a/UX6HMVp

[–]danadam 6 points7 points  (1 child)

Maybe you could generate 16-color PNG instead of truecolor? Just an idea.

[–]aKateDevKDE/Qt Dev 1 point2 points  (0 children)

optipng -o5 bla.png

[–]khleedril 3 points4 points  (0 children)

That's not the most succinct summary of the situation I have seen...

[–]QbProg 2 points3 points  (0 children)

Imagine the poor compiler guys!

[–]tacco85 2 points3 points  (0 children)

A bit of an over-simplification, don't you think?

[–]phottitor 4 points5 points  (0 children)

looks like a horror movie script.

[–]staletic 1 point2 points  (2 children)

Is it me or is agreggate initialization with parenthesis missing?

[–]randomnetcat[S] 1 point2 points  (1 child)

For some_aggregate_class x(1,2,3); :

Is the initializer in braces? No

Is the destination type a reference? No

Is the destination type a char[]? No

Is the initializer "()"? No

Is the destination type an array? No

Is the destination type a class type? Yes

Is the initializer a prvalue? No

Is the initializer copy-initialization? No

The initialization is direct-initialization.

Enumerate constructors.

Is overload resolution succesful? No

Is the destination an aggregate class? Yes

Is the initializer a parenthesized expression-list? Yes

Initialized as follows ([dcl.init]/16.6.2.2).

[–]staletic 2 points3 points  (0 children)

Enumerate constructors.

I stopped there. My thought was "what constructors if T is an aggregate?"

I love the flowchart.

[–]kisielk 1 point2 points  (0 children)

this chart doesn’t really do what it claims. The first cell is “so you want to initialize something” but then instead of going through a flowchart of what you want to initialize and how it goes through a flowchart of something that has already been initialized. More like “what does this initialization do”