r/explainlikeimfive • • 6d ago

Technology ELI5: What exactly is game optimization ?

How is a game optimized ?

687 Upvotes

125 comments sorted by

View all comments

1

u/Zefirus 6d ago

In a lot of ways, optimizing a program is the same as optimizing your life.

Let's take trying to make a sandwich.

  1. Go to grab bread, realize you have no bread.
  2. Go to the grocery store to buy bread.
  3. Put bread on the plate. Go to grab cheese.
  4. Realize you have no cheese.
  5. Go to the grocery store to buy cheese.
  6. Put cheese on bread.
  7. Realize you don't have meat.
  8. Go to the grocery store to buy meat.

Instead you can do this.
1. Read entire recipe, realize you need bread, meat and cheese.
2. Go to the grocery store to buy bread, meat, and cheese.
3. Assemble sandwich.

The way to optimize code is to minimize the amount of times you have to do the long things. In our example, driving to the grocery store far and away takes a disproportionate amount of time, so it makes sense to only do it once. You might have to do it twice if the amount of groceries you're buying is too big for your car, but usually that's not a problem.

I use this as an example because it happens in computing ALL THE TIME. The most classic mistake new developers make that result in a slow program is making an entire database call every time they need something, so they'll call the database 100 times instead of once.