Hacker News new | ask | show | jobs
by exDM69 3390 days ago
> However, is it common for production C code to have a single file with 5,300+ lines?

It's definitely not uncommon, but yes, that file is on the long side. However, it is rather clean and well-organized.

It may be due to the poor module system (header files) of C where you end up making files slightly longer than ideal because splitting into two files means also adding some header files and thus adding to the maintenance burden.

When writing C code, I usually strive to put a whole "module" in a single file, so that no "private" interfaces have to be put in header files. Everything that needs to be exposed in order to test a module goes in the public interface.

It's a tradeoff and C being C doesn't help (and C++ wouldn't really help here IMO), but I see nothing wrong with the file you picked. It's a bit long but it looks well done to my C programmer eyes.