Hello Ayush,
Program optimization or software optimization is the process of modifying a software system to make some aspect of it work more efficiently or use fewer resources.
In general, a computer program may be optimized so that it executes more rapidly, or to make it capable of operating with less memory storage or other resources, or draw less power.
Optimization can occur at a number of levels. Typically the higher levels have greater impact, and are harder to change later on in a project, requiring significant changes or a complete rewrite if they need to be changed. Thus optimization can typically proceed via refinement from higher to lower, with initial gains being larger and achieved with less work, and later gains being smaller and requiring more work.
It's likely that an optimised program will be smaller than the unoptimised program, but it depends on the exact nature of the optimisation changes you make.
Also relevant is how the compiler for your chosen programming language converts your program (game) and assets into machine code. Sometimes its results are counter-intuitive.
For example, if you have a for loop in your game you may choose to “unroll” it into longer code that doesn't involve a loop, which may result in a larger program, that runs more quickly and efficiently after compilation.
Another example might be optimisation of image assets. You can process PNG, JPG, etc. to reduce their filesize whilst maintaining quality. Xcode actually goes one step further and whilst building/compiling your game changes the order of bytes in your image assets so they match the order expected by the GPU on your iOS device, meaning they can be loaded/processed more quickly when your game runs.
Updates always need to work from the original download or the game on the disc. That size is set in stone, therefore updates can only add to that file.
- If you have a game 10Gb and an update 2Gb you can’t make the files smaller afterwards. You can only optimise before going public.
- If you wrote a game 10Gb and then optimise the code to 8Gb you can’t safely replace the file. What happens if there’s a bug in the second version? What if someone has a problem with the first version (they download it and stop auto-updates) and the helpline only works for the second version?
- You’d need to store separate updates depending on which version you bought. Then you’d need the software to know which version it is and only update in specific ways, that’s not going to make the code smaller.
- Also, some games have multiple updates and you need to run each one as they fix different things. If update one fixes bugs and update two fixes multiplayer, you still need to update both.
Basically, optimising code can only be done before the game goes public, not after .
Hope this is helpful!!
Thank You!!