What's wrong with C++?

Pages: 12
Next time someone complains about C++ to you, point them to this article:
http://blog.codeimproved.net/2010/07/whats-wrong-with-c/
I would rather fuel their fire and point them here:
http://yosefk.com/c++fqa/
as in, since they aren't going to be programming in C++ anyway, might as well make them look stupid?
I just tell them "Well, what is wrong with C++, is that it isn't nearly complicated enough to scare away the right people. Other than that it is perfect." Fuel their fire by way of pissing them off, though it makes you look like a major fanboy.
I think C++ did have a lot wrong with it, but with the recent changes that it really is a new language and is much better, more modern, and not enough people realize the difference it makes. Sure, you can still use it like it's hard to use, but why not use it like it's easy to use?
Last edited on
closed account (Dy7SLyTq)
im not nearly advanced enough to find major complaints, but i wish that they would follow boost and make a standardized (emulation of a) weakly typed data type (or at least container) like boost.any
closed account (S6k9GNh0)
My complaints about C++:

1. From a parsing perspective, C++ is the most god awful POS to lay across this land. It's complicated, slow by design, and just plain messy.

2. C++ sometimes suffers from limited syntax due to restrictions to C, but otherwise does fine. e.g. its thought that template syntax is bad simply because of it's choices to follow C closely.

3. If just about every C++ programmer claims that C++ is vastly different from normal C code, then why care about backwards compatibility? "I'm glad this C code works in C++. Makes my life easier" said nobody ever. It's cool that C++ can include C headers but there should be different mechanisms to handle that than causing issues with the entire language.

4. Forced use of exceptions. Seriously not a big deal since you don't have to use the STL but I personally don't feel that exceptions are a life saver and should always have a direct alternative (similar to what Boost does).

All of the rants in that post are things I hear all the time and they're issues with all languages, even languages like D who try and fix them by language constructs. It's not easy to do and there's never going to be a perfect solution to any of them.
Last edited on
4. Forced use of exceptions. Seriously not a big deal since you don't have to use the STL but I personally don't feel that exceptions are a life saver and should always have a direct alternative (similar to what Boost does).


I must be the only person in the C++ world who prefers exceptions over checking for error code returns. At least sometimes it feels that way.

Also, I'm not super familiar with Boost. What alternative does it provide?


EDIT:


3. If just about every C++ programmer claims that C++ is vastly different from normal C code, then why care about backwards compatibility?


I think this is just legacy from C++'s infancy. It was designed to be "C with classes" and sort of evolved into its own language.

We're stuck with it now not because we're trying to keep compatibility with C... but because we're trying to keep compatibility with the millions of lines of C++ that has already been written.

"I'm glad this C code works in C++. Makes my life easier" said nobody ever


Being able to #include, call, and link to C without any additional work is huge. You probably take advantage of it all the time without realizing it.
Last edited on
computerquip wrote:
3. If just about every C++ programmer claims that C++ is vastly different from normal C code, then why care about backwards compatibility?
Disch wrote:
I think this is just legacy from C++'s infancy. It was designed to be "C with classes" and sort of evolved into its own language.
That is how I feel too. However I do not think that
Disch wrote:
because we're trying to keep compatibility with the millions of lines of C++ that has already been written.
is a large problem: people tends to use older compilers with legacy code anyway.

computerquip wrote:
4. Forced use of exceptions.
I wlill be a second person to like exceptions :)
Also compilers often provide option to turn off exceptions/RTTI/whatever if you do not need it.

My problem with C++ is inconsistencies within standard library (like lack of make_unique, which will be fixed in C++14) and lack of often used function overloads: for example applying algorithm to the whole container is the most popular use of it, but we still do not have overloads so we could use std::sort(myCont) instead of std::sort(myCont.begin(), myCont.end()).

std::locale: it is useless. Every operation system, every compiler has it's own list of locales and the way how to represent them in strings. So I cannot create cross-compiling code with locale at all.
In C++14 there would be parts of optional parts of standard which is not required to be implemented for compiler to be C++14 conformant.
I would like to see locale standartized at least in optional part.
closed account (N36fSL3A)
Never encountered any of these problems at all besides the sort thing, and something with std::swap, it's not working with pointers...

So I have to write 3 extra lines of code to swap.

*Realizes how much I have to learn*
Lumpkin wrote:
and something with std::swap, it's not working with pointers...

http://www.cplusplus.com/reference/algorithm/iter_swap/

Although for pointers you should probably keep to using the plain swap, to clarify the intent:

std::swap(*p1, *p2);

Cubbi wrote:
as in, since they aren't going to be programming in C++ anyway, might as well make them look stupid?

In case that was directed at me, I don't understand what you're talking about.
Last edited on
closed account (N36fSL3A)
@Catfish
http://img843.imageshack.us/img843/6555/vrpx.png
It's complaining that it can't deduce the type of the template parameter -- are those pointers to the same type?
closed account (N36fSL3A)
One is void, the other unsigned char. Should I have casted it to void?
Lumpkin wrote:
One is void
to swap pointer values you should dereference pointers and swap values.
What do you think you will got whed dereferencing void pointer? Why do you need void pointers at all?
closed account (N36fSL3A)
I am working with SDL_Surface* s and a void pointer is a member of the struct. I would like to swap a flipped version of the pixels with the original value, save the image contained in the surface, then swap the pointers back to properly free the memory.
so you want to swap pointers, not data they point to?
First of all, you're not supposed to access members of SDL_Surface directly; secondly, you aren't allowed to dereference void pointers or perform arithmetic on them; and third, you can't call a template function f<T> with arguments (A x, B y) because the compiler won't know whether to use A or B for T.
closed account (N36fSL3A)
Yes.
Lumpkin: You should not modify SDL_Surface's pointer to pixel data. That horribly violates encapsulation. The pointer must not change... only the pixel data itself can change.

Therefore attempting to swap that pointer is a bad move. The only way that'd work is if you swapped the entire pixel buffer, but that is a large copy and therefore can't be a simple swap.


So yeah.. .swap isn't broken... it's just that what you're trying to do is conceptually flawed.
Pages: 12