3 ms·
Some years ago, doing high performance dense matrix code in C, I replaced a bunch of modulo calls with a bunch of bit operations. You had to work with matrices
by tom_b 17y ago
Some years ago, doing high performance dense matrix code in C, I replaced a bunch of modulo calls with a bunch of bit operations. You had to work with matrices that were a power of 2 in rows and columns, but you could pad it out and stuff worked.
A year later I looked at the code and couldn't figure out how it ever worked in the first place . . .
- jacquesm 17y ago> A year later I looked at the code and couldn't figure out how it ever worked in the first place . . . Isn't that the norm ?
- tom_b 17y agoProbably. It actually had the opposite effect on me. I try to keep my code cleaner and more understandable now. I'll stick in better, more expansive comments in difficult spots. I'll schedule a code review with peers. If I can explain/justify an ugly hack maybe it's not so bad. But sometimes the fundamental "wrongness" of some piece of code just drives me to try and find a better fix. One of those classic trade-offs, elegance vs expediency.
- jacquesm 17y agoSimilar experience here. When I look at code I wrote 20 years ago I always get the impression I was a better programmer then than I am today simply because it takes me a lot of time to understand what I was trying to achieve. My 'new' code looks so simple and direct in comparision. No more trickery with setjmp and longjmp and no more abuse of side effects. Then I realize that the simplicity is actually better, not the hacks of old. What is surprising though is that it seems almost as if every generation of programmers has to learn these lessons all over again.