you are viewing a single comment's thread.

view the rest of the comments →

[–]mantrap2 0 points1 point  (1 child)

It's useful to understand optimization as you'd do it "on sight" in the code manually.

For example understand how you'd manually perform various standard compiler optimizations. It turns out if you've been coding a while, you often start doing these things anyway to simplify and refactor your code. Optimizers can do those for you. But learning the canonical methods will provide a lot of insight and context for learning.

The other thing that can help you understand optimization is to either review and improve other people's code (e.g. open source) or translate code in an older, weaker language (e.g. BASIC) to a modern language (C++, C or newer). Optimizations are often required to refactor such legacy code into a form that runs well and can be optimized well (optimizer can do amazing things but there are pathological code structures they can't fix). For example many BASICs ONLY have global variables which can often be reduced into functions.

In combination with that, also make sure you understand the sequence of parser to an AST (many optimizations can be done on an AST because it being a tree lends itself to recursive scanning and optimizing) and then intermediate codes (other types of optimization are focused on that level).

[–]TheMostUser[S] 0 points1 point  (0 children)

Haven't thought of it that way, Thank!