The title says it all. In general, is it better to have multiple small files linked together, or one large file?
At least in the web, I know that you should have one or very few CSS stylesheets, to better control the style across different pages and all. As for HTML, it's pretty logically one per page. But what about JS?
And most importantly, the main point of my question is, what about other environments and other languages? Does this depend on the language or the goal? If so, what are some examples or cases where one method is better than the other?
Regardless of which is better, is it defined just by convention, or is it because of performance?
BTW, this is first post, so I'm sorry if I missed something, and please let me know!
The idea of "files" is, for the most part, an abstraction developed to help people make sense of the contents of a disk. It's a lot easier to envision chunks of storage as documents with names and extensions and so forth than it is to try to work with byte offsets and lengths. Think of trying to find your way: street signs and buildings and landmarks help you orient yourself by dividing and delimiting space, but if you're lost in the desert, one sand dune looks much like the next.
It is perfectly possible to write programs in a single file in many languages, but tools that allow multiple source files to be "linked" into the finished product date back half a century for a reason: it makes an enormous difference to our ability to comprehend how individual parts of the system work and interact with each other. The ways in which programs may be divided into source files vary wildly depending on language, purpose, convention, and taste. But those are all essentially human factors. It doesn't matter to the computer.