4 ms·
This looks sweet, but 6KLoC file. How do you even do that and stay sane?
by Keyframe 12y ago
This looks sweet, but 6KLoC file. How do you even do that and stay sane?
- blablabla123 12y agoI frequently see such long files when looking at typical C or C++ projects, actually both closed and open source. Most other languages seem to have unwritten laws that source files shouldn't be larger than 500 LOCs.
- to3m 12y agoProvided you avoid globals, the sky's the limit. My professional record is 17,000 lines; after a while it became a game, to see how far we could take it before somebody cracked. But in the end the project finished before anybody felt the need to split it up. It was actually very easy to keep on top of and handy to have everything in one place. You do need some better way of navigating round the file than search, though! I recommend something like visual assist or imenu.
- blablabla123 12y agoHaha, sounds like fun
- awalton 12y agoI don't see why people have such a problem with long source files to be completely honest. I'd rather do refactoring in one source file than edit 10 and wonder if I hit them all. None of my other tools care about file length - it might actually take longer to build if the code were multiple files since most of the processing overhead will be in invoking the process and the context switching between the make tool and the compiler - modern C/C++ compilers can handle 10kloc files in their sleep. In fact, in many projects that I've done with "correctly split" source files (one per class/object impl), I've seen that often the license and the general file boilerplate is actually longer than the code that goes in that file. It actually costs more for the compiler to handle this case, as it is doing even more useless I/O.