by mikekchar · 6y ago · 0 comments
I specialise in legacy code. I've seen my fair share of abysmal code that works. This is pretty awful, but far from the worst I've ever seen in my career -- even in systems where public safety was critical. I've not looked at this code in any real detail, but I suspect John Carmack (who has doubtless seen a fair amount of complex C code in his life) has it right.
On the plus side, if anyone wants to practice refactoring gnarly C code: here's your opportunity.
He explicitly writes there:
"it turned out that it fared a lot better going through the gauntlet of code analysis tools I hit it with than a lot of more modern code. There is something to be said for straightforward C code. Bugs were found and fixed, but generally in paths that weren't enabled or hit."
"the performance scaling using OpenMP was already pretty good, and this was not the place for one of my dramatic system refactorings. Mostly, I was just a code janitor for a few weeks, but I was happy to be able to help a little."
and
"I can’t vouch for the actual algorithms, but the software engineering seems fine."
As shown, he even points that the believes "a lot of more modern code" would have been worse than that "straightforward C", which matches my experiences.