Only c and c++ are good languages.
Wrong.
C and C++ are both terrible languages for very different reasons.
But all programming languages suck to some degree.
Ways in which C sucks:
- The language is so barebones that basic types like bool weren't added until 2003, making a lot of older code fundamentally incompatible with the new stuff, so nobody uses it. not having real bools, generics, real constants or real references causes a lot of unnecessary issues, reduces type checking, and generally makes C an absolute minefield to work with. Why have a nice, well-defined generic delegate class (or functor<>, in the case of C++), when you could just use void* and get no help from your compiler at all!
- Manual includes results in a lot of headache and extra work, which people supplement by using tools like cmake. Cmake is absolute cancer and nobody should use it, but your alternative is either complex makefiles (which are impossible to maintain), or a severe lack of encapsulation.
- Object Orientation is impossible. Some people see this as a feature, but the reality is there are some applications where inheritence is a very good approach (eg component widgets for a GUI). C programmers claims inheritence is possible, which is true, but it involves horrible individual memory hacks, things like purposely writing over the end of a struct to fill a different struct with the same overall layout plus additional fields. None of this is supported by the language and is very prone to breakage.
- The language is so low level that doing any sort of high-level logic is impossible, even in places where appropriate. A better made language would pass around references and let you work on them. C is likely to give you a void*, return an integer error code, and overall require you to know the ins-and-outs of every specific details of every object you're working with. This contributes to making abstraction harder, if not impossible, and is why C programmers can never quite get into the "move customer to new manager" mindset rather than "assign Customer* pointer to a manager struct's 'employees' array and make sure you check the error_flag variable to make sure it's not -1". It's madness. Low level implementation details are constantly getting in the way of high-level business logic, and vice versa.
Ways in which C++ sucks:
- It's effectively 3 languages in one, with 2 of those languages being deprecated. Do I use int i = 3, or do I use int i { 3 }. Don't use auto_ptr, it's deprecated. But books still mention it. As do guides. Many codebases rely on it. C++ has a lot of deprecated features that are still present and that you shouldn't use, but which even a well-read developer could miss because of how commonplace and accepted they are. This is largely caused by the next problem...
- The standard library is a complete mess. This is largely because it was implemented as a set of free functions working on iterators, rather than being a set of abstract classes which can be extended to implement things like lists. As a result, application code isn't tied to interfaces, it's tied directly to library functions. This makes it impossible for the C++ team to remove old cruft or update any library functions, because code relies on their existing functionality. Even if this was still impossible with an interface-based approach, it would be easy for people to simply swap out one implementation for another in their codebase if they are passing the interfaces to their classes/functions as needed. The C# standard library works like this and it's way better to use as a result.
- C++ lacks language niceties from other languages (like properties) because they are "unsafe", and yet I can do plenty of unsafe things like redefine the = operator to cause a memory leak. The language lets you do some really powerful and dangerous stuff, which is good, but the standardisation team seems to have missed the memo and is refusing to add features that are "too dangerous" as a result. As a result, C++ is both very easy to break your codebase with, and yet also doesn't have the language niceties required to actually abstract things nicely. It's the worst of both worlds.
Overall, I still really like C++, way more than C, and I use C# for my day job and it also has plenty of problems (the implementation of "interfaces" rather than using abstract base classes or allowing multiple inheritence being one of it's biggest issues), but the languages are beyond broken in many ways,
Ideally, I would like someone to create C+, which is basically
- C style syntax, plus classes, templates, properties, and some other nice OO and C++ features
- None of the C++ bloat
- Proper imports, rather than includes.
- A well structured standard library based on abstract classes
- Full Multiple Inheritence support, no stinkin' interfaces!
- No need to be backwards compatible, a clean slate, so we can get rid of the cruft from both C (BOOL, #define, etc) and C++ (auto_ptr, etc)
- Separate operators for integer and float division, since that's a pet peeve of mine.