Jump to content
  • Advertisement
Sign in to follow this  
wcassella

Criticism of C++

This topic is 1061 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've seen people criticize the C++ language in many different ways, and while much of that is legitimate, sometimes I feel they're missing the point. Probably the biggest compiled collection of criticisms would be the C++ FQA, which is a great example of what I'm talking about. Some of the earlier points about header files and undecidable syntax are agreeable awful, but some of the other points don't make a whole lot of sense. Defects 7, 8 and 9 are especially questionable, but I'm not going in to those. I just want to take a chance to rebute some claims against it I've seen online and in person.

 

It has duplicate funcionality

The most popular example I've seen of this is pointers and references,  which I strongly disagree with. This is like saying that 'int' and 'float' are duplicates, since they both store numbers. While pointers and references can be seen as a means of "referencing" something, the way they work and are used (and the concepts they represent) are fundamentally different. Namely, a pointer is a value in itself, while a reference is not. I think "alias" would have been a better name, which may have reduced some of the confusion. It's also worth pointing out that references may not be null (the only way for that to happen would be to dereference a null pointer, which is undefined behavior), but in practice I have seen that occur (though not without having made poor mistakes). One thing I really like about references is they are the only thing I've seen in any language that actually indicate how "array[3] = 2" might work.

 

It's unsafe

This one I can empathize with, since it is much easier to write fundamentally broken code in C++ than in most other languages. However, the example of this I've seen people bring up is almost always pointer arithmetic, which is strange since that almost never occurs in real code (the only common case would be when its wrapped up in an iterator), and there's much easier and subtler ways to write broken code anyway. I guess this is just another example of people criticizing something without actually having much familiarity with it. In practice C++ can be very safe if written correctly, though I do wish it was just a bit safer, since I already have enough trouble sleeping at night.

 

The syntax is ugly

There are some cases where C++ can be a bit ugly (array declarations are weird, semicolons after classes are funky) but it's really just a matter of aesthetics. I think APL is pretty fuckin' ugly, but that's mainly because I don't understand it. C++ is in some cases much more verbose than other languages, but that's usually by necessity rather than design. Lambdas for example simply can't be as clean and pretty as those in C# because it would require the compiler to automatically decide whether you want to capture by value or reference, which would be unsafe (though it would be cool for zero-capture lambdas to be that pretty). C++11 has done a lot to make the language much more concise in some areas, and concepts are only going to make it better.

 

In conclusion

I'll probably think of more and edit this post when I do. There are a lot of things C++ could do better, and I feel like much of it goes back to having been built directly on top of C. However, there are a lot of things I think C++ has done well that I miss when working in other languages, and it bothers me when people unjustly criticize it.

Edited by Salty Boyscouts

Share this post


Link to post
Share on other sites
Advertisement

I'm really tempted to actually level some genuine criticism at C++ here, but I have a feeling what you really want is to defend the language for some reason or another. (I won't call into question the validity of your reasons. Yet.)

 

Go ahead!

 

The main exigence behind this was a conversation with one of my coworkers a while back, he's a smart guy but he loves to get into arguments even if he doesn't fully understand the positions. C++ is not without its faults (I certainly have my own laundry list of complains), but I feel like its issues are not as clear cut as some people seem to think.

Edited by Salty Boyscouts

Share this post


Link to post
Share on other sites

... which is why people keep making new languages to compete with it.

which is the typical system 2.0 issue, thus when I see ppl reinventing the wheel, to have 'some' new features, while at the same time missing tons of features that evolved in c++ standard and non-standard compilers, I just cannot take then serious.

I suggest everyone who thinks that c++ has issues, to come up with ways to improve the situation. the c++ standard discussion is public, everyone can contribute and there you'll get feedback why some stuff is one way or another, hence it can make ppl understand why something is one way or another.
also, if you talk with the creators of some features and you get to know, that the solution you've preferred was one of 20 and they've implemented and evaluated then all, you'll think twice about complaining.

pure complaining is not helpful if you have the chance to change something.

Share this post


Link to post
Share on other sites

 

C++ is a flawed language - mostly due to the compilation model or decades of accumulated evolution - but most criticisms I've seen of it are even more flawed, and most of them basically boil down to "this language doesn't abstract away the underlying hardware enough for my taste."

 

Yup. Language wars are silly because it doesn't make sense to use only one language in the first place. Every language has its weak points and every language except for Java has its strong points. You just have to know what's available and use the right tool for the job.

 

 

Believe it or not, some people consider checked exceptions to be a good thing, so according to them even Java has its strong points.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!