Ask HN: Has Anyone Tried Single File Development with IDE Code Collapse?
One of the primary benefits I've found is easier code portability. With all the code in a single file, you can simply drop the file into your project without worrying about dependencies or file organization. Refactoring also becomes more straightforward since you can see all the related code in one place, making it easier to update dependencies and related functions. Additionally, LLM assistants often perform better with code completion when all the code is in one file, as they can access the entire context more easily.
I've noticed that other projects also take a single file approach. For instance, SQLite concatenates all its C files when it's built, there are single file header projects like STB^1 that tout ease of use, and even the .NET garbage collector^2 is a single 56k file. So, this approach is not entirely unprecedented. With modern editing tools, this method seems more viable than ever before. What does everyone think?
1. https://github.com/nothings/stb 2. https://github.com/dotnet/runtime/blob/main/src/coreclr/gc/gc.cpp
4 comments
[ 2.7 ms ] story [ 16.3 ms ] threadAt some point in time, some dev splits the file to get faster responses again.
Despite this, we have no issues, git works fine and search and navigation in the code is also just fine.
I really cant work with ppl creating separate files for (sometimes) a 10loc function, just because it seems unrelated to the rest of the package. Its like implementing code folding on filename level…