2 ms·
> you won't be going anywhere in computer graphics by trying to "write pure functions" or "avoiding side effects" Not sure about this; in my experience (in a d
by tomn 4y ago
> you won't be going anywhere in computer graphics by trying to "write pure functions" or "avoiding side effects"
Not sure about this; in my experience (in a different domain, audio processing) you totally can get away with both of these a lot of the time.
Function inclining works well, so you can write small pure functions in a lot of cases (especially if you accept a function that reads from one buffer and writes to another as pure).
As for avoiding side effects, this is normally more about keeping your state updates small and localised (allowing more parts to be pure), which is often not a problem performance-wise.
IME it's much easier to improve the performance of a piece of code which is easy to reason about and change with some level of confidence that your optimisation will not break things.
I know there's some unavoidable global state in computer graphics, but presumably there is lots of code that doesn't directly touch that.