from Hacker News

Ask HN: Has Anyone Tried Single File Development with IDE Code Collapse?

by Decabytes on 11/1/24, 8:51 PM with 3 comments

I've been exploring a different approach to organizing my projects by keeping all the code in a single file and taking advantage of the code collapse feature available in most modern IDEs. I'm curious if anyone else has tried this and what their experiences have been.

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

  • by frnkng on 11/2/24, 6:25 AM

    We also do this. For us, the limiting factor is the IDE getting slower with bigger files. For IntelliJ+Kotlin the big file handling got better over time, but if files get bigger and bigger, the response times of auto completion and other ide features gets slower and slower.

    At 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.

  • by solardev on 11/1/24, 10:22 PM

    Sounds like it would be difficult to work on a project with other devs this way, and the git history would look like a Christmas tree at a disco party...