Jul 10, 2017 · 2 min read
I think every sane developer will agree with you in that, that switch is crap. It goes so much against the KISS principle, and yes, that’s not an exception in C++. I have a lot of different complaints against C++:
- All the legacy stuff from C. For example, the concept of header files. Modern languages come with packages not with headers. Most information in header files are redundant.
- Names (who decided that
unorderer_mapwas a good name for a hashmap? almost every other name was better (table, map, hashmap, dictionary…). By the way, why putting all functions from the STD in thestd::namespace? It’s absurd, it makes me writestdeverytime but gives almost no clue to the reader, Go approach is much better here. - Too much complexity, C++ is bloated with lots of features. Again, simplicity has been sacrificed all over the place, there are lots of different ways of doing the same thing (more with each C++ revision).
- Slow compilation times. Mainly a result of the template system.
Yet I program in C++, why?
- Libraries, the Qt library for example is one of the best GUI toolkit libraries. For example, I’m a huge fan of Go, but there is nothing similar to Qt for Go, not with the same level of quality. OpenGL is another good example, nothing similar can be done in any other language without calling to C (yes, there are bindings, but they have its own little cons).
- Performance. I write 3D graphics programs, in this case, and in many more, performance is critical. I spend much time optimizing code, programming in Python is not an option, programming in anything different that C/C++ is a risk. I used Go for a graphics app once, and the results were good since its GC is really good, but at the end you know that there is a limit with other languages: GC, runtime, lack of SIMD intrinsics, compiler (C/C++ compilers are very mature)…
- Flexibility. This is a double-edged sword, but in general everything that the CPU can do, you can code it with C++. With other languages there are limitations: memory/pointer restrictions (see Rust, an entire language oriented towards memory safety, or Go, pointer arithmetic is forbidden and all memory is zeroed by default), run-time code generation…
For example, now I’m working on a 3D graphics app, it requires access to the GPU (OpenGL, DirectX or Vulkan), a multi-platform GUI toolkit and high performance (compiled language and very low GC pauses), do you think that C++ is not least bad language in this case?
