Why are there code files more than 10k lines long? #15728
Replies: 2 comments 1 reply
-
Besides coding agents not being set up well to handle this (but they don't do that well with low-level code anyways), there isn't a big difference in how easy code is to understand between a huge file and many small files. You jump from function to function and read the parts relevant to you, while ignoring the rest. |
Beta Was this translation helpful? Give feedback.
-
Yeah I have to agree, but it seems better than it used to be 6 months ago - there were a couple of near 20k line files back then that were really painful to deal with! 😄 I suspect the reason for it is to keep the compile times short. The gamedev community also did this at one time or else it could end up taking all morning just to perform a build! They eventually moved to custom pre-processing jobs that keep everything as smaller file but then concatenate some or all for the actual compilation... I seem to remember watching a conference video where this was also found to actually increase the performance of the final compiled binary by 10-15% - due to avoiding the "friction" at the boundaries between the linked objects, and letting the compiler see optimisations that it would otherwise miss for the separated files. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I was working in the code recently and realized that several of the code files are massive - like 10k lines long or more. For higher level code, this is bad enough. For low level code in C/C++, it makes it effectively impossible for other people to comprehend or even just read the code.
I also tried using AI powered coding agents to see if they could analyze this mess, and it quickly blew out the contexts of both the local and cloud AI tooling I tried. Even models with extremely high context windows were no match for this code.
Please consider refactoring the codebase to make it more understandable by others.
Beta Was this translation helpful? Give feedback.
All reactions