C++ grievances

October 8th, 2009

I love C++. I think its great, despite the fact that it is the epitome of Worse is Better. STL is a powerful weapon, and iterators allow you to mix and match what ever you want. However, here is a list of things I hate (some of this comes from C):

  • Classes. Great idea, but why do I have to terminate them with a semicolen? Also, I think D has a more preferable syntax on constructors. Speaking of, forwarding inherted constructors back up to their parent is just a PITA.
  • Array Syntax. Granted arrays aren’t used much in C++, but every other type places the modifier on the typename, not variable name. A pointer to an int is int* foo opposed to int foo. A constant int is const int foo. A reference is int& foo. An array is int foo[]. The brackets come after the name, and appear to be a part of it. Unless its a function prototype with no name, in which case (and only is this case) is int[] acceptable. WTF?
  • Those who say that using C++ is opening the door to memory leaks and crashing from invalid delete, etc. This is true of C yes, but not C++. If you’re not writing a library, and you’re using pointers instead of references and smart pointers (#include <memory>), and the boost:: or std::tr1:: smart pointers, you’re doing it wrong.
  • People who use using namespace std; for anything but trivial projects.
  • The conception that putting a if (foo) { (notice the opening brace on the same line) looks okay.
  1. No comments yet.
  1. No trackbacks yet.