One uncommon style convention we have in the Bun codebase is putting imports at the bottom of the file instead of the top of the file No one wants to see 100 lines of imports before seeing the actual meat of the code
@zack_overflow well, I think it's uncommon because it doesn't even work in most languages
@zack_overflow 100 lines of imports.. surely that’s a modularity code smell?
@zack_overflow sir, "import statements must be at the top"
@zack_overflow someone should try one of those LLM coding benchmarks and see if they do better if they're prompted to put imports at the bottom
@zack_overflow Maybe you can put them in a separate header file ending in .ts.h
@zack_overflow Those that work in languages that can't do this must be a bit miffed about it. Also, 100 lines of imports is a lot of imports to have in a single file. I really hope this is gross exaggeration, for the sake of the developers.
@zack_overflow why do so few languages have the concept of import modules (like Swift)?
@zack_overflow I jump to symbol definition rather than directly opening a file, so I never see the top of a file.
@zack_overflow I know an engineer who worked on a massive java project and they moved all imports to a separate file to make the codebase more readable. team's productivity shot up like 30% after that change 🔥
@zack_overflow Functions can also be written in execution order, top down, instead of bottom up like in most languages.
@zack_overflow Functions can also be written in execution order, top down, instead of bottom up like in most languages.
@zack_overflow why would no one want to see what tools a file consumens at the top?
@zack_overflow That's dumb. You should see what is coming before accessing meat. Gotta know the spices you have before starting to cook
@zack_overflow Why would we have 100 lines of imports in any codebase today? Honestly, this is a quirk that is antithetical to productivity. A smart guy once said smart engineers optimize for things that shouldn’t exist…
@zack_overflow Wait is this in JS? Don’t the imports have to be at the top?
@zack_overflow I like the way Odin handles imports personally. Just the module is imported and modules are much larger than zig’s where each struct is a module. Massively reduced import cruft.
@zack_overflow I feel code editors need sections that are dynamically resortable
@zack_overflow I’ve actually started doing this too, especially for scripts and smaller modules. Top heavy imports kill flow when you’re scanning for logic. Let me grok the control flow first, dependencies can come after. Makes way more sense when you’re reading than writing.