An introduction to why your game is slow - Part 1

lancelotdulak

Active Member
Nov 7, 2018
556
549
I thought some of this was interesting. some wrong.

Mostly i think all or most of you especially op have lost focus.

If youre programming in a scripting like python,renpy,basic speed is not and can not be a goal period. What renpy does is give you simple data structures and switches etc and the ability to display an image or video

If you want something more powerful you use unity or UE4.. both which are far more powerful than any of this genre needs. You can indeed make aaa games with it.

Beyond that you go to C, C++, C# etc.. you can do this within unity/ue4 and get Speed and efficiency. Beyond that.. within c/c++ you can use assembly.. which is as fast as it gets.

With literally ONE exception everything on this site could easily be written in any of the above and will absolutely not tax your hardware period.

Most slow code is because programmers use API's which they either dont have access to the internals of or dont have the time to study that deeply. High level programming is INCREDIBLY inefficient. Most of the games you play with 5gb, 10gb downloads dont need anything close to that amount of space if coded efficiently from the ground up. But at each level in the chain more and more efficiency was added. And remember that physic api in the code has layers of inefficiency built below it . It is this way because it saves programmer time. To write something like Battlefield 4 from scratch in assembly and pure c or c++ using no outside api's would take eons.

The hardware we use is incredibly efficient at what it does. Your gpu is VERY good at graphics and floating point math. It SUCKS at everything else. Your CPU is an all around processor. It can do literally anything. It's far slower at floating point math and graphics than your gpu (but it can do them and this was once the norm). It can do sound.. its far less good at sound than a sound chip or board. Your ram is Offcpu fast storeage.

If you want to write things that are fast. Dont get over complicated.. KISS. Use the lowest level language you can. Use pointers to data structures. etc PS one of my big nitpicks about this was the obsession about linked lists. All variables are simply pointers to areas in ram. We use variables because it makes it simpler mentally. That's it. Google Malloc and Calloc. At it's heart thats how variables ,ram and memory work. Nothing more complex. When you allocate a certain kind of variable it will reserve a spot in memory for that number of bytes.. 1, 2, 4, bytes .. whatever. Or groups of those . myArray[a] will reserve X * A bytes starting at the position pointed to by myArray where x is the size of the individual variable.


The secret to fast code is being efficient , clever, unlazy and going back and optimising over and over. It's that simple. Unfortunately with the combination of MS and C++ being the norm these days you ahve a lot of lazy programmers who only understand the surface and not what is below the api's theyre using.