Why is C++ so shit?

Why is C++ so shit?

The only widely used language worse than it is Java, probably.

Other urls found in this thread:

harmful.cat-v.org/software/c /I_did_it_for_you_all
twitter.com/SFWRedditGifs

Because it works, and everyone else uses it.

>worse than it is Java

The sentence is grammatically and factually correct.

>Why is C++ so shit?

Why did you make this thread suggesting it is if you didn't know the answer yourself?

This

*worst then its java

>Why is C++ so shit?
Because it's based on C.

Oh good, it's the "C is bad because it doesn't hold my hand" meme

Go program in Scratch and leave competent people alone.

That reply is a complete non-sequitor to what he posted.

What he said is true, the most egregiously retarded things in C++ come from C, e.g.: non-hygenic macros, header files, and dumb type coercion rules.

> works
> c++

pick one

Why is *insert any language here* so shit?

The worst parts of it aren't from C, though

Why is gif so shit?

Because god hates us -_-

>thinks C++ is unreadable
Someone hasn't seen a single line of Perl in his life.

>Why is C++ so shit?

Here's a story:

>Hey Bjarne, I'm integrating a 3rd party API
>Bjarne: Yah?
>I'm making some calls out to it, that I want to wrap in a try/catch block
>Bjarne: Yah. It's C++, so you can do anysing you vant.
>So, I have some cleanup that I want to do in a finally block, how can I do that?
>Bjarne: Oh, yah, you cannot do zis.
>Uh. But you just said I could do anything I want.
>Bjarne: Yah, you can. But not zis.

Between its half-assed C roots, and Bjarne and the C++'s Committee's weird obsession with particular patterns (e.g. composition, iterators), it's become a complete shitfest. The latest involves weird overloading of existing stuff (e.g. using) all because they're so desperate to never, ever require anyone to rename something in their shitty old codebase.

Hell, I just read something the other day about the classic problem where you can create a situation where you can't tell if something is a function or a variable declaration. All of that basically boils down to the effects of not simply declaring functions with the fucking *function* keyword.

Pascal was so much better than C++...

It wasn't really worth typing out all that greentext just to let everyone know you don't understand how RAII works. C++ doesn't need a finally block.

> you don't understand how RAII works.

Yeah, because I want to write wrapper classes (that's what we called them before "RAII" become the dumb, easily misheard buzzword) for every damn resource in a one-off use.

At least optimize it fucktard.

Do you really want to know the truth?
harmful.cat-v.org/software/c /I_did_it_for_you_all
Trigger warning

Java shits on your C for most practical tasks.

its getting a lot better.
still a lot of ugly shit in it.

>retards unironically defending java

Sup Forums has truly gone to shit.

You don't need to write classes for everything to have it destroyed when exceptions are thrown, that's what unique_ptr is for. Moreover the STL containers mostly obviate the need to even bother with that most of the time since they manage their own memory.

RAII became a popular buzzword because people stopped writing C++ like you've been when C++11's featureset started to become implemented.

>You don't need to write classes for everything to have it destroyed when exceptions are thrown, that's what unique_ptr is for.

Is there anything better than college freshman Sup Forums lecturing?

Dumbfuck, there's a reason I mentioned external APIs several times. Consider any situation where some resource is freed. I'm not talking about new/delete. I'm talking about some_api_get_object() with a later some_api_release_object(). Now consider a sequence of events, like getting a handle to a file, opening the file, looking for specific data, etc. In other words, the entire reason why 'finally' is a thing in other languages.

>RAII became a popular buzzword because people stopped writing C++ like you've been when C++11's featureset started to become implemented.

"RAII" was the term long before C++11 came about, kid.

>Pascal was so much better than C++...
oh wow

That's still wrong, retard.

>underrated post
underrated post

why abandon arrays????

>I'm talking about some_api_get_object() with a later some_api_release_object()

That's what unique_ptr is for. The constructor takes an optional parameter to a custom deletion function if just freeing the memory doesn't suffice. Meaning you can use all kinds of clumsy C APIs without cluttering your code reproducing manual memory management idioms or writing your own wrappers. I'm writing a program now that interfaces with SDL and uses unique_ptr to manage resources by automatically calling SDL's own deallocation functions on scope exit. Finally blocks are less powerful than this and don't add anything the language doesn't already have. Read the documentation.

Fine then, what do you think the best language is?

>pro tip: There isn't one fuckass

>best language
that wasn't what OP's post was about, he's just shitting on C++
learn3read5

>That's what unique_ptr is for.

That is one use for it. That is not "what it's for".

> Meaning you can use all kinds of clumsy C APIs without cluttering your code

You and I have very different interpretations of "without cluttering your code".

>Finally blocks are less powerful than this

I'm not after "more power" than a finally block. I'm after a finally block.

>and don't add anything the language doesn't already have.

It doesn't have a finally block, like every other civilized language since the 1990s, not to mention Windows's structured exception handling.

But yeah, you make a fine point: you are exactly what is wrong with C++. Instead of just giving us a fucking finally block like people wanted for literally DECADES, they instead came up with a way to make the code profoundly convoluted and hideous, while cleverly "solving the problem" in a way that nobody ever wanted.

I already ran pngcrush -brute over it. What program do you use?

>You and I have very different interpretations of "without cluttering your code".
>hey instead came up with a way to make the code profoundly convoluted and hideous,

The program I was referring to above has zero inline resource management. Just some type aliases to unique_ptr at the top of one of the files stating clearly how each struct is freed. If our interpretations are any different, yours must be more permissive than mine. Something's a bit off about your ideas of "convoluted" and "hideous", too.

This is an example of code that calls SDL functions and assigns to managed types. Spot the "profoundly convoluted" resource management.

at least put in some effort

I just bought this book, Will it teach me the magical ways of C?

It'll teach you the basic semantics of the language but nothing practical like large scale design or memory management idioms or debugging and makefiles. It's considered a classic but it'll only get you halfway there.

i already know about malloc(sizeof(penis)) and free(penis)

Made by the creator of the language as you know. No better way to learn the basics.

Knowing what malloc/free do does not make you knowledgable about memory management in real-world use cases, just like reading the pthreads API spec won't prepare you to write concurrent code that doesn't crash and burn

Are you retarded?

"The only widely used language worse than it (referring to C++) -> is Java, probably"

Does it make sense to your primitive brain now?

well im not doing it for a living just as a hobby and if something breaks ill just ask pajeet on stackoverflow.

Holy shit, is that code a joke? Ridiculous abuse of 'auto'.

Everyone should be using C#. It is the good sides of C, C++ and Basic combined. Why isn't there a widely used C# compiler for Linux yet?

Also it's the only programming language I know so it would be really convenient if you guys could get to it by next month.