Edit: Really enjoy threads like this, because you learn and see so many Pov.
My favourite answer (not in this thread unfortunately) was:
*”If you write a story, the number of words you use can affect the reader’s experience.*
*Use too many words, and the reader takes a long time to get through the book, has difficulty remembering everything, and can’t separate what’s important and what’s not.*
*But use too few words and the reader will get an incomplete picture, make mistakes in understanding the story, and eventually become disinvested in the book.*
*A poorly optimized game is like one of these examples. Either too much goes in, making it difficult for the hardware to cope, or not enough goes in, making the game buggy and broken. (Sometimes both, but that’s beyond ELI5).*
*When it comes to optimising a reader’s experience, it is not about putting more or less words in but choosing the right combination of the right words at the correct time in the plot. Optimising a game is similar concept.*
*Most importantly, no matter how well you write a book, there are always people who will think it could’ve been written better, especially by them. “*
In: 404
A simple explanation is that code can be written fast and run slow, or written slow and run fast. You spend initial time writing code that is easy+fast to write (but slow) and then if it becomes a problem you can more time later to rewrite it so it runs fast.
One of the examples, assuming we’re going from zero knowledge is sorting numbers. If you have the numbers 1 to 1000 all randomly arranged, what is the fastest way to sort? The first naive approach would be to go through each and check to see if the one you currently have is the lowest. So if you picked 500, you would go until you have 499 or lower. Once you do, you start over again. Keep going for 1000 numbers. It would take many thousands of iterations to do this, take up tons of CPU and just be a terrible choice.
Now you enter the realm of optimizations and you have to choose what to optimize for. In the sorting example there’s about 100 different options. Some are optimized for low numbers of things to sort, millions of things to sort, CPU optimization, memory optimization, speed etc. One thing to sort may not be like another so you could be using many different sorts.
You can see this visually here: [https://www.youtube.com/watch?v=FNAUuYmkMPE](https://www.youtube.com/watch?v=FNAUuYmkMPE)
[https://www.youtube.com/watch?v=kPRA0W1kECg](https://www.youtube.com/watch?v=kPRA0W1kECg)
Another version of optimization you can easily see is pathfinding. How to get from A to B: https://www.youtube.com/watch?v=g024lzsknDo
Latest Answers