C++ is a mess and you should feel bad for using it

c++ is a mess and you should feel bad for using it

Attached: tumblr_nwyatdXIRS1si194ao2_250.gif (245x265, 1.97M)

No and you have to be a retard to handicap yourself to C if you don't have to.

what's the alternative?
>inb4 rust
kys
>inb4 c
kys

t. brainlet

alright, name 3 valid reasons for your optinion that can not be easily discarded with a simple counter argument. im waiting.

btw, just because its popular to hate on something doesnt mean you must do that aswell.

Attached: chineseBoie.jpg (800x533, 67K)

C++ has a lot of good ideas, and in isolation it's easy to see why they're useful, but on the whole I feel like it's easy to get lost in the sepplesisms when you're compounding all these things together. Whenever I'm writing C I feel I'm spending more time looking up library function calls, whenever I'm writing C++ I feel I'm spending more time looking up C++ language features and STL calls. Maybe someone more comfortable with C++ doesn't have this problem, though, or maybe it's just because they've developed one out of a million ways to write C++ and just stick to it, it's honestly hard to tell.

Attached: 1550587077684.png (481x481, 332K)

OP is right. Only legit use is as C with classes. "Modern" C++ code is full of std::cancer and exceptions which are also cancer. I see a lot of C++ code like a hello world implemented in 500 lines that is a single main with like 20 lambdas made by some fucking genius that way because muh idiomatic. It's almost worse than Java.

C++ doesn't really have that many language features.
I limit myself somewhat to my personal style and if I don't know how something work I will just use a safe way.

How is the stdlib bad? How is a vector bad? How is std::string bad?

don't act like you think that's what anyone is talking about, you know damn well the standard library is more complicated than a few new types.

Ok, what are the bad parts?

C with classes sucks, all the new shit exists to fix the problems with it. In particular, there's no point using C++ without RAII. You may as well just go back to C at that point.

They are almost OK but look at the new stuff, absolutely horrible.
Also recently I needed to mess with strings and for performance reasons I couldn't afford messing around on the heap. I fucking hated the API that was expecting std::string...

Vala

C++11 and C++14 are the only valid choices, if you want a higher level language go for Haskell

You're just too much of a brainlet to use it.

i just use it like C with a couple classes for overall structure/inheritance
pretty comfy, dont even use std::vector

>[C++] certainly has its good points. But by and large I think it's a bad language. It does a lot of things half well and it’s just a garbage heap of ideas that are mutually exclusive. Everybody I know, whether it’s personal or corporate, selects a subset and these subsets are different. So it’s not a good language to transport an algorithm—to say, "I wrote it; here, take it." It’s way too big, way too complex. And it’s obviously built by a committee. Stroustrup campaigned for years and years and years, way beyond any sort of technical contributions he made to the language, to get it adopted and used. And he sort of ran all the standards committees with a whip and a chair. And he said "no" to no one. He put every feature in that language that ever existed. It wasn't cleanly designed—it was just the union of everything that came along. And I think it suffered drastically from that.

Ken Thompson; cited inSeibel, Peter (2009).Coders At Work. p.475.

it really is a huge piece of shit but it's unavoidable depending on what you want to do

I've been learning c++ for a while now and I remember bursting in laughter when I saw the keyword "friend" was a thing.

#define fren friend

Attached: cpp.jpg (1750x463, 192K)

I almost never use friend, but it can hate its uses.

kill JS and we have a deal

The more you use it the less you'll have to look shit up if you end up using those features readily enough. Same as any other language man.

C++ is alright but you need a proper style guide and scan-build. Our management recently wanted to switch from Ada to C++ and i straight up told them to fuck off.
>Breivik
What a unit.

yes

Attached: em.png (1190x232, 63K)

wanted to post this aswell, was not disappointed
c++ is(better said was) good and dandy until you reach the syntax powered by the never-ending expansion/changing of their libs & niche "features"

kys

use Rust, it's the ethical choice

Hey C++fags, aside from this bait thread, let's discuss the phases that C++ developers go through.

I had the following ones:

1. big functions with lots of loops and ifs
2. object-oriented everything
class Class1{
std::vector matrixOfClass2;
void function();
};
3. lolol fuck std::vector, it's slow and I don't have the control I want.
int* matrixContent = new int[1337*1337];
int** matrix = new int*[1337];
for (int i = 0; i < 1337; ++i) matrix[i] = matrixContent[i*1337];
delete[] matrix;
delete[] matrixContent;
4. lololol that's so unsave, I'm going to make my own stl now!!!
template
class MYvector{
Type* content;
//...
};
5. lololololol template features are super super cool! I'm going to make everything super complicated.
6. fuck me I can't build everything myself and it's too complicated and the debug messages get really crypric. It's still cool though. The stl isn't so bad if I know how it works under the hood.
7. >discover intrinsics __m512 is SO COOL
8. >tfw my cpu does only support SSE4
9. __m128 is allready much faster and intrinsics are really cool.

That's where I am now. So what was you C++ journey? If you further, what is the next phase?
Also, I figured I need to learn assembler now, as I feel like I am not getting everything out of the CPU with intrinsics if I don't exactly understand the way cashing works. Is that true?

1. C++ is so hard, I wanna go back to game maker
2. Wow I'm so cool I made my first game in C++
3. C++ is best language ever, I'm going to write everything in C++
4. My C++ programs keep crashing and doing weird shit. There must be a way to prevent that.
5. Start using all the linters, sanitizers, compiler warnings under the sun
6. Wow, this Rust language looks totally gay
7. Try it out regardless
8. Wow, this is like C++, except all the linting and shit is done by the compiler, and it's even more strict
9. Ugh, this is suffocating. I can't do whatever I want because the compiler keeps cockblocking me.
10. Maybe I'm too much of a brainlet to be a programmer

1. everything is a class with getters and setters
2. nothing is a class, abuse namespaces
3. only interfaces and invariants in constructor warrant classes, everything else is a struct + free function in namespace
4. just do whatever the coding style says
I've always (ab)used templates, they're alright. Recently i've added lambdas, std::variant and std::visit to the list of things i abuse.

I like abusing casts, like

uint64_t x;
((short*)&x)[0] = 10;
((short*)&x)[1] = 20;
((short*)&x)[2] = 30;
((short*)&x)[3] = 40;

uint64_t y;
((short*)&y)[0] = 5;
((short*)&y)[1] = 6;
((short*)&y)[2] = 7;
((short*)&y)[3] = 8;

x *= 3;
x += y;
std::cout

undefined behavior, faggot

I just don't like header and macro hell

No, it isn't. If you know how your system architecture works, that is.
Sure, you can theoretically have some insane implementation of C++ that would break it.
Sure, you could have a short type with 32 bit that will crash it.
But on x86 and all other sane implementations, it will work.

the really fun question is, what will happen if you do this:

uint64_t x;
*((int*)(((short*)&x)[1])) = 1337;

fuck me, meant
*((int*)&(((short*)&x)[1])) = 1337;

Replace short with uint16_t and then it should be guaranteed fine, I think.

Attached: Screenshot_14.png (1331x320, 17K)

>What is strict aliasing?
you're retarded and you don't know the first thing about C++

I don't even use it at all.

that's tame.
You can also "rob" a class.

class PrivateClass{
bool b_thatIsPrivate;
int x_thatIsPrivate[512];
int y_thatIsAlsoPrivate[512];
float z_thatIsPrivate;
};

class HackedClassPewPew{
public:
bool b_hacked;
int x_hacked[512];
int y_hacked[512];
float z_hacked;
};

function hackIt(PrivateClass& a){
((HackedClassPewPew*)&a)->x_hacked[100] = 1337;
((HackedClassPewPew*)&a)->y_hacked[100] = 1337;
}

faggot, I know that you are not "supposed" to use that.
But I also know that long and short use the same cash to store their data, so that it actually (secretly won't cause problems if you do that).

this. is unaligned access, so it's much more dangerous.

Also violates strict aliasing, also invokes undefined behaviour.

There's no "supposed to" about it. If you do it, the compiler is permitted to generate nonsense.

also does still work.
unless you have really bad luck with compiler optimizations.

permitted to != will actually generate nonsense.
But chill, I would never use any of those things in actual production code because I know that this might mess up things in the far future when new processor architectures come out and people wounder why it stopped working. Or if someone uses it in a different context where it wasn't tested.

>I don't really have seen have that many language features of C++.
FTFY

also, "function" hackIt was suppoed to be void before someone calls me retarded for it.

What about this then:

float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;

x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed

return y;
}

doesn't it also violate the "rule".
Or would the way to go be to use reinterpret_cast?

And if not, then what is the point of reinterpret_cast? Wouldn't it always violate the strict aliasing rule?

Sure it does. Reinterpret cast should only be used for conversions to/from char* and unsigned char*, which behave differently to other pointers.

The "safe" way to do type punning is to use memcpy. Sane compilers will optimize it out.

>not c
kys

>Sane compilers will optimize it out.
The same way sane compilers will use autovectorization? I doubt it tbqh.
As far as I know, the casting from all integer types into each other is save on all modern implementations.

me :
>want to dev gud cross platform GUI comfily
>open Qt Creator
>Comfy GUI C++ development

Ctard :
>gggggghh gtk
>gggggh muh vim
>it takes 2 months to set up your buildscripts,1 month to configure vim
>4 months to learn GTK on some retarded freetard website
>2 months to program your GTK Hello World
>duh only wangblowers or xfce normies need GUIs anyway

Rustard :
>what is a GUI ?

Javatard :
>Shauchalay kahan hai ?

Attached: 71k0YgQX4nL._UL1500_.jpg (1500x1403, 108K)

just use electron lol

>GUI
retard

I don't have the room for a computer cluster

Spoken like a true retard.

Attached: linus.jpg (183x275, 8K)

Attached: arch.png (1465x1007, 117K)

You only need to open one web browser per GUI component, it's not that much in todays world. Memory and CPU is cheap.

eat a dick op

oh okay, I remember atom taking 20 seconds to open at my UNI and I know discord is shit too so it makes me hate electron quite a bit

>He uses MOC

Just use gtkmm like an actual human being.
Also:
>Not using cmake for C and C++