I totally agree. I'm not sure what its like outside of the game industry, but I've used C++ for about 20 years now and I am increasingly disappointed with its many failings every year. Its a bloated, complex language full of dangerous, sharp-edged features which often interact badly with each other. It drifts farther and farther from the systems-programming language I actually need, with every generation of the standard.lucasart wrote:obfuscated templates libraries may be useful for experienced C++ programmers who understand the arcanes of the STL (at best 1% of amateur C++ programmers?). But saying that they make life easier for beginners is such falsehood, it's not evne funny.
http://yosefk.com/c++fqa/templates.html
I have made a choice to use these nasty things to a minimum and only when they are actually useful. There are some many C++ programs that make a point of using all the defective C++ feature there is, as if their code was written to impress someone about their knowledge of the language. What matters is to write simple, maintainable, portable code. The rest is masturbation, IMO.
As a matter of fact, all very large projects written in C++ inevitably become an unmaintainable mess, that only some C++ gurus can fix (at huge cost, especially when the code is written to use all C++ obfuscated STL there is).
I know some game developers who like STL, but my own experience has been that only a few parts of it are really worth bothering with.
std::sort and std::lower_bound are great, and std::vector is usable if you don't already have something better (but every game engine I've worked on has something much better, because variable-sized arrays of homogenous data are used everywhere in games because they are cache-friendly, and it pays to have something smaller and faster and easier to debug and less code-bloat-causing than std::vector). Same thing for std::string, although that one is good enough for most purposes. If you wrap them carefully enough, stl::map and whatever hash_map also come in handy. I struggle to think of anything else from the STL or the C++ standard library that I would willingly use, and language misfeatures like exceptions, RTTI, virtual base classes and pointers-to-members are safest to just completely avoid.
Iostreams are a clunky mess, I've never seen a problem where they were the right solution. Same goes for C++ exceptions which are a total disaster-zone. You can throw anything you want, but how to catch it? Interop with C gets hard in the presence of exceptions, and most programmers can't write reliable exception-safe code. (I think most of the ones who think they can, are deluding themselves. I certainly wouldn't claim to be able to write exception-safe code, and if you know you can't do it correctly anyways, I suggest not trying to do it at all!) even if we wanted to use exceptions, game engines have to run on platforms which don't even support them anyways.. None of the built-in smart pointer types are worth trying to build on. Linked-lists are worthless if they aren't intrusive; <algorithm> is a joke, sets are not generally more efficient than maps. At the extreme end of C++ness, you end up with something like boost, which is a serious case of mad-cow disease.
If you want to write high-level programs, write them in ANY other language besides C++. Most languages have decent bindings to C that you can use for high-performance parts. Or you can embed LuaJIT or a JavaScript VM and alternate hard and soft layers. But I think the most useful niche for C++ is still, using it as a better C to write low-level programs. C plus syntactic sugar, virtual methods, simple container classes that manage their own memory, const references for passing large, read-only parameters, and the convenience of RAII. But the deeper you drink the C++ "kool-aid", the more problems you create for yourself that you will then have to solve! The 10th time you get a crash inside a 1KB block of heavily-templated code and the debugger can't even tell you what types the template was instantiated with, you will realize that those "benefits" you thought you were getting from using "proper" C++ can also be serious liabilities. Being able to debug your code is significantly more important than saving 1 line of boilerplate with something from <algorithm> will ever be.
