Ha! Interesting clash with this interesting approach taken by John Carmack (of Id fame).
On the subject of code duplication, I tracked all the bugs (problems that surfaced after I thought everything was working correctly) I fixed for a while, and I was quite surprised at how often copy-paste-modify operations resulted in subtle bugs that weren’t immediately obvious. For small vector operations on three or four things, I would often just past and modify a few characters like this:
I now strongly encourage explicit loops for everything, and hope the compiler unrolls it properly. A significant number of my bugs related to things like this, and I am now rethinking even two dimensional cases where I commonly use discrete _X, _Y or _WIDTH, _HEIGHT variables. I find that much easier to read than a two element array, but it is difficult to argue with my data on how often it made me screw up.
It’s not a clash. This blog points to the performance benefits of unrolling, Carmack points out the quality negatives. As always, it’s up to you to make the trade-off. Now you have the pros & cons, which do you choose? (And how do you know if you made the right decision?)
Ha! Interesting clash with this interesting approach taken by John Carmack (of Id fame).
It’s not a clash. This blog points to the performance benefits of unrolling, Carmack points out the quality negatives. As always, it’s up to you to make the trade-off. Now you have the pros & cons, which do you choose? (And how do you know if you made the right decision?)