<bybbworld />

Why I chose C++ to build a game engine?

I chose C++ to build my game engine for the challenge. The first version of my game engine was written in Java using LWJGL. I had never used C++ pointers before so I decided to use C++ to build the engine. I already knew most of the OpenGL stuff, so it was just a case of learning C++ as I built the game engine.

C++ is a very different language from Java, despite looking sort-of similar. Whilst Java does not force the programmer to work with pointers, C++ does. However, C++ pointers are not that compicated for the basics, and that's all you'll need most of the time.

Pointers allow you to decide whether you're refering to the actual data, on the location in memory of the data. Pointers are a really good way of expressing arrays as well, with each item in the array just being the location in memory of the first, plus the index multiplied by the size in bytes of whatever you are refering to. You can store data or pointers in an array. ASCII strings can also be treated as arrays, so it is a pointer. With one byte per character, you just reference the memory address of each byte.

C++ also doesn't force you to make everything a class, something that Java does. This is a downside in Java sometimes, as you may just want a function, but you have to make a class for it to be able to use it everywhere. In C++, this isn't the case and you can have functions wherever you want!