flyx.org

Personal homepage of Felix Krause

Reasons why C++ sucks

Disclaimer: This list is not and will never be complete (but I may update it if I'm bored). It also contains strong language.

Preprocessor

  • Yeah, it has a fucking preprocessor. The preprocessor is a feature of C because C lacks so many features that the preprocessor is needed. Nobody cared to include tools in C++ to make the preprocessor obsolete, so it still lurks around and takes your firstborn children.
  • You still use the preprocessor to include headers. So if you have a syntax error in one header, let's say, a missing semicolon in the last line, the compiler complains giving a line in a completely different file. The proper way to do it would be to parse headers separately before including them.
  • Oh, and because you still have to use #include, you obviously need those shitty #ifndef guards in every fucking header file. Yeah, if you have a fancy compiler, you can use #pragma once. Well, unless the gcc guys decide to deprecate it.

Type System

  • C++ has a bool type. It is the most idiotic boolean type you will ever see. Firstly, you can use any integral type in a place where you need a boolean value. This leads of course to programming errors like if (i = 2). But if you actually decide to use the bool type, you run into funny stuff, for example: An uninitialized bool variable may be neither true nor false - depending on your compiler, if you define bool a;, both a and !a may evaluate to true.
  • Enums are really dumb. Take for example:

    enum traffic_lights {
        RED     = 1,
        YELLOW  = 2,
        GREEN   = 4
    };
    

    As you may expect, this is just an int with some named constants. You can declare multiple values with the same value, you can assign int value to it. And if you do YELLOW++, you don't end up with GREEN, but with a value that isn't defined in the enum (but doesn't raise an exception either). You also cannot iterate over existing enum values. At this point, this is just useless syntax sugar for

    #define RED    1
    #define YELLOW 2
    #define GREEN  4
    
  • Oh, did you know, C++11 does introduce enum class. It fixes none of the issues described above, but makes you prefix the enum values with the name of the enum. Well done.

  • Strings are still C strings. Yeah, you may have heard of std::string, which is a type that is somewhat better than a raw char*, but the problem is, string literals are still char*. They get converted to std::string in some places, but it does not work everywhere. For example, this doesn't compile: "a" + "b".

  • Typedefs everywhere! If the error message of a compiler (at least gcc) mentions for example std::string, it does not output std::string, but std::basic_string<char>, because it's a typedef. This gets really ugly with more complex types.

Functions

  • Function parameters are mutable by default. This is bullshit. The usual case is that you don't want to modify a function parameter, because they are passed by value and won't be copied back. It is also horribly inconsistent: Reference type parameters (those with myriads of & around them) are actually always const (that is, you cannot change the reference, but you can change the referenced value).
  • Functions that don't have void as return type are not required to return a value. Seriously? This just screams for bugs if someone somewhere forgets to write return result; and the compiler doesn't remind him.

Templates

  • You have to put the complete implementation into the header. This slows down compilation considerably, because all the fucking implementation of the fucking template is parsed every fucking time it is fucking used. Oh, you can of course try to use precompiled headers and open the door to hell.
  • You can use the keywords typename and class for template parameters, and they do exactly the same. You can put a class into a typename parameter, and you can put a non-class into a class parameter. So what's the point?
  • If you use a template parameter for defining a type within the template implementation, you often have to put typename in front of it. Example:

    template<typename T> a() {
       typename std::vector<T>::iterator t;
    }
    

    It wouldn't compile without the typename. And if you miss it, the compiler will probably give you an error that is extremely hard to understand. If you get some huge error message when compiling a template implementation, add more typename.

  • You cannot constrain type parameters. For example, you cannot declare that a type parameter has to be a child class of some other class. You just assume random things about the template type, and if someone else uses in a way you didn't plan for, he may get error messages pointing to the implementation of your template. There was a feature called Concepts that was planned for C++11, but it was dropped (and may come in C++14).

  • Support for value parameters is very limited. For example, you cannot declare a template taking a parameter of type std::string. You can declare a template parameter of type char*, but you cannot directly pass a string literal to it. You have to define a char* constant with external linkage somewhere and use that as template parameter.

Object Orientation

  • this is a pointer. Why isn't it a reference? It may never be null, and if it is, your code is broken anyway.
  • The compiler generates some methods of a class automatically based on complicated rules. Examples are the assignment operator, a copy constructor and such. You can also instruct the compiler to not generate these methods if they would be automatically generated. Some of these methods are needed for using the class in the standard container structures like std::vector, so you have to check all this stuff every time you declare a class.

Standard Library

  • The smart pointers (std::unique_ptr et. al.) are a sorry excuse for a missing language feature. A class usually has no idea about whether it is accessed with a smart pointer or not, but when it passes a reference to itself somewhere, it needs to know. So you suddenly have to derive from std::enable_shared_from_this to be able to convert this to a smart pointer.
  • Iterators are simply a huge mess. To implement a custom iterator, you kind of need the iterator module from the Boost library if you want to have it done till the end of the year, and even that is really complicated to use.

Tags: programming

In-depth Review of Skyrim's Gameplay

Preface

This is a review of The Elder Scrolls V: Skyrim. Or, perhaps more accurately, a review of current / “modern” action-adventure video games in general. I write this as someone who likes JRPGs, old-school video games in general, and particularly the Zelda series. I also do tabletop roleplaying.

I bought Skyrim because it was on sale on Steam, everyone seemed to like it and I was searching for a bit of distraction. I didn't play any of its predecessors. And I stopped playing it after two days, so I guess I didn't make it far into the storyline. My response to anyone who'll tell me that I'm being unfair because the game gets better later will be “well, it should be good from the beginning”.

Starting a new Game

Some characters get introduced, factions are mentioned, you get to see some of the scenery. I have to say, the thing I like about this game most is the scenery: It is really a nice and not too repetitive walk through nature. Now I get to designing my character. Everything is customizable. I feel like installing Linux.

I quickly get the feeling that all this customizability is just an illusion. There are plenty of predefined presets for characters, but they all look grim and dirty. Now perhaps the storyline's setting is one that requires grim and dirty characters, but this just isn't my style. If I'm given the option to customize my character, I want there to be the possibility not to look grim and dirty.

This is a psychological thing, you know. Define a character for a game without any customizability and everything's fine. Give the player customizability options, and the player has to live with the fact that the appearance of his character was his choice. If I cannot customize the character the way I want, I'll be less satisfied than I would be without customizability.

Anyway, this is just a minor issue compared with the others I will come to. So after having chosen a race, name and appearance for my character, I soon get the ability to move freely, equip a weapon and some magic. I can choose whether to walk around in some light armor or in a mage robe. That's nice, I guess. Well, as it turns out, it doesn't make much of a difference.

Fighting Mechanic

So, what's the difference between fighting with magic and fighting with a sword? The answer seems to be, not much. I have to equip the sword / fire thingy, target the opponent, and activate it. The sword delivers a strike, while magic is an ongoing action that just continues to deal damage. Fighting with a sword requires stamina, spellcasting requires Magicka. So being mage seems to boil down to still just hitting your opponents until they go down, but you're exhausted more quickly and have shitty armor.

The only way that gives you a real choice regarding combat style is to use a bow. I like the way you can sneak upon enemies and just do double damage as long as they don't notice you. Unfortunately, once they do notice you, you'll have a hard time with your bow and need to switch to meelee weaponry.

This is another time where I get the feeling that the game just gives me the illusion of a choice. I cannot be a mage that does not primarily do direct damage, nor can I be a pure sniper. Especially boss fights usually require meelee attacks and you cannot do much about it.

Fights do not tend to allow much tactics either. The enemies just run towards you and try to hit you. Compare this to the enemies in the Zelda series: They often require a certain move or equipment to kill them. In my opinion, this delivers a richer and more diverse gameplay. In Skyrim, you can choose whether you want to kill your enemies primarily with your bow, or your sword, or your magic. But once you've chosen, you'll just do it over and over again.

Of course, you just have to build up some meelee skill because you often wander around alone in Skyrim. This is imposed by the overall game design and I don't see a way to do it better. Other people don't seem to mind, so it is possibly more an opinion than critism.

Overworld

The overworld is just gorgeous and probably my favorite thing about this game. I know how much work it is to craft such a vast and diverse world, and it has been done really well. It even provides some interactions with all the plants you can pick.

The map is nice and the option to fast-travel to places I have been before avoids repetitive travelling. There are signs at every junction so I don't get lost as long as I stay on the tracks.

Dungeons and Enemies

Okay now seriously, this is the worst part. I think this whole dungeon thing is a massive fuckup by game designers. Action-adventure games in the early days had this simple structure where you have this overworld thingy that gave you access to the dungeons, which were the “levels” of the game.

Roleplaying games have a similar structure, but the difference is that you travel with multiple characters with different abilities, and this works very well in combat situations. In Skyrim, it does not work, and you know why? Because it tries to be an action-adventure where you're controlling one guy (or gal) who explores these dungeons, but at the same time it tries to be a roleplaying game where you should be able to shape your character.

By having dungeons which you typically have to fight through alone, the game requires you to be a killing machine, because that's how you survive the dungeons. You can of course specialize in the speech skill so you can buy weapons for less money, but you still need to wield them yourself.

Another massive failure is that the dungeons are just not interesting. Okay, so I only played the storyline until I reached High Hrothgar, so it might get better later, but what I saw was just… caves. With zombies. And then more caves, with more zombies. Even the city of Whiterun has catacombs, with skeleton zombies. Okay, to be fair, there are also som spiders, and in some cases thiefs, but that's it.

Again, compare this to the Zelda games, or RPGs like Final Fantasy: The diversity of enemies is much higher, as is the diversity of settings and dungeon theming. Now this has an obvious reason: Skyrim tries to deliver much more realistic consistence within the world it describes. Remember infiltrating the Shinra headquaters in Final Fantasy VII? There are flying enemies composed of razor blades or something strolling around. Does this make sense? Rather not. Is it fun? Sure!

Skyrim castrates itself by maintaining a high level of in-game realism. There just cannot be some random creatures strolling in the dungeons. If you're exploring ancient ruins, there will be zombies. If you're digging into caves, there will be zombies. And if you're entering a haunted barrow, there will of course be zombies.

A lot of people will say that this is a good thing, because the more consistent the in-game world is, the more you can dive into it. This is true and it works really well for the quests available in towns, but it makes it really difficult to design interesting dungeons. That's why I said earlier that dungeons are not really necessary in this game.

Levelling

Levelling up gives you the option to raise one of your basic values - Magicka, Health, or Stamina. Additionally, you can buy one additional skill from a huge set of skills that are divided in quite some categories. So it does give you the option of shaping your character more like you want him or her, but as I mentioned earlier, you can hardly get away without buying some combat skills.

A good thing is that you cannot just specialize in just one skill category, because you have to actually train your proficiency in each category before you can by all of its skills. Again, this is very realistic, and in this case, I don't see much bad side effects, other than you cannot say “I just want to be a warrior” and only buy direct combat skills.

Conclusion

Skyrim tries to be too many things at once. And action adventure needs more diversity in enemies and fancier dungeons to stay interesting and avoid being repetitive. A classic RPG needs more characters so that each of them can really specialize in one thing or the other. A realistic RPG does not really need dungeons, because you actually want to focus on the role you play, and the combat system is only a minor part of this way of playing.

Moreover, compared to tabletop roleplaying, realistic role playing in a video game is utterly limited. You can only choose the paths and only make the decisions the game creators designed for you. Therefore, I think that realistic role playing just does not belong on the PC. A video game should either be an action adventure with more unusual enemies and fancier dungeons like Zelda does it, or it should tell an interesting story with complex characters, as Final Fantasy (and many others) does it.

Of course, this is a very subjective point of view, I know that. Many folks seem to like Skyrim's approach to role playing and gameplay. And Skyrim does have its bright sides, like the brillantly crafted overworld. But in the end, I got bored pretty quickly. I guess I'll just stick to tabletop roleplaying for the realistic RPG experience.

Tags: gaming