games
pages
posts

iconOptimization

2000-01-01

Optimization is good. The hardware I own usually is some years behind the newest one available at the time, so that alone makes me appreciate when something has as much raw performance as possible. There just is no good reason to make something use up more resources than it needs. Why waste CPU cycles to make it run 10 times slower, if you can optimize to make it run twice as fast? Why use twice as much memory as needed, when you can optimize to use only half as much?
Optimization is bad. It takes a lot of time better spent on implementing and improving the rest of your program, and the result is code which is hard or impossible to understand or modify, which is less robust, and maybe even has some subtle bugs. Why do something in a convoluted and complicated way, just to save some extra checks or a few bytes of memory here and there?
So, there, that's my opinion on optimization.
Put in a different way, there is no clear yes or no answer. There's always trade offs. The first one, it simple takes time to optimize working code. But of course, if you can make the code work better, and maybe even easier to understand, then it's good to take the time to optimize it. Another trade off maybe, you can either optimize for size or speed, or something else. Such other thing may be robustness, correctness, or code readability. E.g. you could write something in C/C++ instead of Python - but is it really worth transfering your working code to something unmaintanable? In many cases, it is - there simply is no way around it. E.g. you can't expect to make a graphics application by maintaining your framebuffer as a python list of lists, and then have it update more than one frame / second.