218: C++ Used To Program Video Games.

Take Up Code - A podcast by Take Up Code: build your own computer games, apps, and robotics with podcasts and live classes

Categories:

Why is C++ such a good choice for writing games? The C++ language is used for many types of projects requiring speed, scale, and responsiveness. It’s also a great choice for video games. Why? The C++ language is more towards the low level of language abstraction but not all the way. And it’s because of this that a lot of people think that C++ is not used much anymore. That it’s been put aside in favor of higher level languages. What about languages like Python or Javascript? Or Java or C#? They all have their use. It’s not like one language is better than another. That would be like asking which is better, a hammer or a tape measure? So which language should you use? It really depends on the type of game that you’re building. But there’s a big advantage that C++ has over other newer languages that attempt to be easier to write. It all has to do with timing and how C++ allows you to write code that’s more deterministic than other languages due to the lack of garbage collection in C++. Listen to the full episode for more details, or you can also read the full transcript below. Transcript The C++ language is used for many types of projects requiring speed, scale, and responsiveness. It’s also a great choice for video games. Why? Well, video games are written in many languages from assembly to graphical symbols you can snap together. The languages usually range from low level such as assembly to high level such as the graphical. I saw a game design product at Target recently that consisted of a grid of squares. It looked like you place colored markers on the squares to define the background of a game. Yellow squares resulted in a coin in the game, blue squares caused water to appear, and brown were used for the ground and floating platforms. It was a simple system that promised you the ability t design your own game. Not a bad idea, really. The only problem is that it looked like you would be limited in the types of games you could design. If you think about the languages available and rank them according to the level of abstraction, then the plastic squares on a grid would be at one end and assembly on the other end. The types of games you can create will be limited at one end and boundless at the other. The C++ language is more towards the low level but not all the way. And it’s because of this that a lot of people think that C++ is not used much anymore. That it’s been put aside in favor of higher level languages. What about languages like Python or Javascript? Or Java or C#? They all have their use. It’s not like one language is better than another. That would be like asking which is better, a hammer or a tape measure? The difference between construction tools and languages though is that you can write a game with just a single language. You can’t build a house using just a hammer. So which language should you use? It really depends on the type of game that you’re building. You can build a 2D game fast with Javascript that will run in a browser window. And maybe more. I’m not an expert with this so can’t say for sure. But I do know that Javascript is getting faster and more capable. Python is a language that I’ve started learning about and using a bit. I haven’t tried using it for anything graphical. And for me, anyway, it starts getting hard to understand as the size of the program gets larger. I’ve mentioned before that a game can get large and complicated quick. You really need some good libraries or a game framework to help you build anything more than a trivial game. There’s several 2D game engines available and some very popular 3D game engines. Unity is a powerful 3D game engine designed to be used with the C# language. And Unreal is another powerful 3D game engine designed to be used with C++. If you want to use Python or Java or any other language, then you should probably find a game engine that supports