So, I have been using C++ informally (and a ton of other things, but C++ was my first) since middle school, which was about 15 years ago. It was nice, all these years, anything I coded using the STL I could rely working on anywhere I took it. Unfortunately, STL doesn't really allow you to do much. So, if you want to try making a simple game or something, maybe a platformer or a shmups, just for fun, you have to grab SDL, OpenGL, mix a few, or something to that effect. So, when I first started using OpenGL, I ran into problems, but I solved them. Then, magically, OpenGL2 comes out.
Unfortunately, everything that you could do before is now totally deprecated, or just doesn't work. Well, that's great. You gotta update, so you do, or try to, but you find out that your hardware just might not be compatible with the new standard that you're trying to compile against. Well, that's even better, right? Ok, let's try SDL instead. Yeah, sure, unless you mix it with OpenGL, you're not going to get hardware acceleration. Oh well, at least it's stable, right? Oh no! SDL2.0! What's this? SDL1 code is broken? Ok, let's try java. Maybe I'll use that cool assembly trick that I learned some time ago that'll allow me to link C++ to Java and then I'll have my universal library! Wait, programs compiled for new JREs also occasionally face features being deprecated or removed?
Alright, so how about this? I stick with STL. STL's nice, and I don't really need it if I am coding on a microcontroller, since I'll have full hardware access. That'll be nice. Oh, it's 2015, and apparently C++ itself has been updated twice since I learned it, and no one even told me. The dinosaur itself is starting to face update/deprecation rot. So far, I haven't had any of my code break due to the new C++ changes. I'm sure someone would blast my coding style to pieces, even before the updates, but with the updates it's worse. But, how long until it does? I'm already reading that there were indeed breaking changes, but none of them had affected any of my code.
So, I look into these changes, the ones that are breaking code and the ones that aren't. We have cool things like Lambdas, which I agree can make some things safer, but were they ever really necessary? And then you have things like the "override keyword." C++ allows operator overloading, so if a class derives another class, writes it's own methods for that class and code intended to call the newer class isn't written right, so it calls the older class, it should be the class' fault, or at least responsibility to prevent it? I'm not even sure how the "override" keyword would even pull this off? Does it blanket out all overloaded functions, or what? Already, you only call the parent IFF the child doesn't have what you're looking for (or if you've casted the object). Just to make sure I wasn't loosing my mind, I decided to test this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <stdio.h>
class kitty{
public:
void meow(){}
};
class kitten: kitty {
public:
void meow(){
printf("Hello\n");
}
};
int main(){
kitten my_cat;
my_cat.meow();
return 0;
}
| |
Yep, without a keyword, it already works. So, why did we add this? Now, I could also complain about how static variables in a class must be defined outside of the class (seriously, why?), but at least that behavior isn't particularly new. Then we have the enum class: enums worked before, but you had to be careful. Now we have a variation of the same thing (and any layman would easily ask why they chose to do it the way they did, instead of calling it strong_enum or typed_enum, which would've made things way, way more obvious), which isn't really necessary, outside of "now we can magically prevent more errors." And what's this about returning multiple variables from a function? I thought that's what passing by reference was for. When you see these kinds of massive additions to the language, you have to ask "Ok, how does this not only impact legacy code that so many businesses rely on, but also how does this affect documentation and tutorials as a whole?"
Don't get me wrong, it does need to be brought up to date a little, but I thought that's what C# was for. What needs to be updated (and also better standardized) is the STL: some of the STL changes have been very, very important and valuable. STL is the rock library of the language: if you want full C++ compiliance, you need to support the full STL (some archs support C++, but not the STL). Meanwhile, the STL has seen threading function support (something that will break STL for certain archs that might've supported STL before), but basic sound and 2d graphics (something like VBE+ [can specify a target resolution and get a linear frame buffer] alone would go a very, very long way, even accepting that it wouldn't be "hardware accelerated") support hasn't been implemented. Yet when you get a new compiler, sometimes you still have to figure out whether it's "<iostream>" or "<iostream.h>" just to use cout, which is a big deal for some new people, and don't get me started on if you want to use something like printf since it's easier to format the output without learning all of iomanip. Plus, you also have how many tutorials out there playing with things like "gotoxy" which doesn't even exist in the STL (i'd still like to know why we don't have a clear screen or gotoxy standardized, yet, to push pressure on the OSDevs to follow a simple universal standard for such a simple functionality).
So I ask, why is it that C++ can't be our rock? Why is it that the changes we're getting are more theoretical benefits, but fewer practical benefits? You'd think that C++ was a philosophy, rather than a tool, at this point. I'm ranting about C++, but this also applies to other old, but gold, languages. C/C++ is essentially everywhere, and I can go ahead and code on any platform with it, including android. I can sit down with my tablet (thanks to the Termux app), turn on a bluetooth keyboard, and code at a campground, just to get some peace from the rest of the world, or maybe on an airplane or at a restaurant. This is all thanks to the universal standards and consistency that has been afforded to C++ so far so that projects like clang and gcc, along with unix and posix standards, have been able to establish the environment in many places.
So, I ask again, what gives?