Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One file of 2600 lines, guess if you give up common sense and follow this approach you can even create a kernel in one file


I am not sure exactly where you were trying to go with this, but 2600 lines is actually pretty short for a C program.


Whose common sense though? You seem to have one particular opinion on how to organize a project, but that's not the only one. Sometimes, having just one file is easier.


Depends on your development style and aims.

One file is easy to add into a project, and the compiler optimizes translation units better, so you get a bit of a performance increase in some cases.

Having "Find symbol in file" is nice too if you know you are looking for it just in this one file related to the code. Most editors aren't as ergonomic for finding "symbol in current directory" as they are for "symbol in current file".


For parsing/protocol handling the implementations where this was distributed amongst several files and/or classes have usually been the worst, in my experience.

But now I want to see how badly you could Uncle Bob this thing. My screen should be wide enough for the resulting function names.


have you ever looked at the source of sqlite?


AFAIK FreeRTOS is a kernel and distributed as a single file.


Maybe that was true at some point, but it’s no longer true. FreeRTOS consists of a core of 6-7 .c files (some of which may be optional) plus 2-3 board support source files. See their GitHub mirror: https://github.com/FreeRTOS/FreeRTOS-Kernel




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: