What are the benefits/drawbacks of keeping all the code in one file?
-
I am currently working on a piece of software where they have 16k LoC in a single file, which people develop in. This is source. Not concatenation/minification/transpilation/compilation/gentrification.
I'm trying to keep an open mind.
Mo' like I'm chasing down my sanity.
-
Benefits: your office stays warm in the winter while the file is open in your IDE.
-
@shoreline said in What are the benefits/drawbacks of keeping all the code in one file?:
16k LoC in a single file
Is there a way to spread that code over multiple files? Perhaps with some sort of more tightly-defined theme to each file? It'd make it easier for people to wrap their brains around.
-
It's easier to understand the folder structure of the source code
-
BRB, asking my fortran-enabled colleagues for the answer to this.
-
Benefits: None.
Drawbacks: Everything.
-
@shoreline What language? That's kind of important.
Until like... 4-5 years ago, JavaScript had no module system (now it has a terrible hacked-together one) and so you didn't really have much of a choice other than to put tons of script in one file.
-
@blakeyrat said in What are the benefits/drawbacks of keeping all the code in one file?:
you didn't really have much of a choice other than to put tons of script in one file.
There are many ways to split code, e.g. creating <script> tags on the fly to load any part of the codebase on the fly and on demand
Not to mention all those disgusting sounding named tools that automatically pack everything and minify/compress it as a bonus, (but that is generated code), even if the language doesn't have it there are (non-standard) viable solutions still.
If you really wanted all the code in one file, there should be adequate support from the IDE to have:- arbitrarily many source panes open on the same file, with separate save semantics
- easy, unambiguous bookmarking and recall of the code regions open in above panes (eg through language structure, or file structure (which should be the same, if a syntax-based code editor ever becomes a thing))
- essentially replicate what text files were supposed to do in the 70's, but packed in a single file (which can't be enhanced, since all filesystems are FAT32)
-
@dkf said in What are the benefits/drawbacks of keeping all the code in one file?:
tightly-defined theme to each file
You mean I should "separate" the "concerns" of code into specific files?
That sounds suspiciously like sorcery.
Another project I've just been transferred from is using webpack, but this one had a month to go and apparently are backs were "against the wall", which implies we'll all be shot if we don't deliver the remaining frontend fixes. Basically I didn't have a chance to implement it. I just wanted to perform a sanity check, since I rolled under on my last one and dropped a point.
@vault_dweller said in What are the benefits/drawbacks of keeping all the code in one file?:
It's easier to understand the folder structure of the source code
I tell myself this every morning when I throw up and hope it's not another phantom
menacepregnancy.@blakeyrat said in What are the benefits/drawbacks of keeping all the code in one file?:
module system... it has a terrible hacked-together one...
I know. I love it! #indoctrinated
-
@bugmenot said in What are the benefits/drawbacks of keeping all the code in one file?:
There are many ways to split code, e.g. creating <script> tags on the fly to load any part of the codebase on the fly and on demand
That only works if the JavaScript happens to be running in a DOM environment like a web browser.
If it's something like ActionScript in Flash or JScript in WSH, nope... there's no such thing as a <script> tag.
In other news, shake out those "If JavaScript MUST BE WEB BROWSER!" brainworms. JavaScript was used in all kinds of places for decades, most of which were not web browsers.
-
Not to mention all those disgusting sounding named tools that automatically pack everything and minify/compress it as a bonus, (but that is generated code), even if the language doesn't have it there are (non-standard) viable solutions still.
If you really wanted all the code in one file, there should be adequate support from the IDE to have:- arbitrarily many source panes open on the same file, with separate save semantics
- easy, unambiguous bookmarking and recall of the code regions open in above panes (eg through language structure, or file structure (which should be the same, if a syntax-based code editor ever becomes a thing))
- essentially replicate what text files were supposed to do in the 70's, but packed in a single file (which can't be enhanced, since all filesystems are FAT32)
All of the wtf points you accrue emulating multi-file support still offset the constant-scroll-athon that happens with current text editors and monitors on special files (btw: anyone using a vertical ultra-wide monitor, does it help any?)
edit: :nod: lost the markdown formatting on c&p, why?
-
@shoreline said in What are the benefits/drawbacks of keeping all the code in one file?:
I'm trying to keep an open mind.
Don't. Kill them. Kill them all. (says he who has to occasionally work in a 23K cpp + 12K h file... yes, we have several hundred other cpp/c/h files in the project too)
-
@vault_dweller said in What are the benefits/drawbacks of keeping all the code in one file?:
It's easier to understand the folder structure of the source code
Our previous lead absolutely forbid that. So we have 1606 cpp/h files in one directory. But the solution has folders! (where in the solution is x.cpp located? Fuck if I know. <opens vcxproj.filter file in editor, search, ah ok>)
-
@bugmenot said in What are the benefits/drawbacks of keeping all the code in one file?:
arbitrarily many source panes open on the same file, with separate save semantics
easy, unambiguous bookmarking and recall of the code regions open in above panes (eg through language structure, or file structure (which should be the same, if a syntax-based code editor ever becomes a thing))
essentially replicate what text files were supposed to do in the 70's, but packed in a single file (which can't be enhanced, since all filesystems are FAT32)I don't know if you're proposing or describing, but Visual Studio does all that except the second clause of the first bullet. (If you hit "save" the whole file gets saved, not just the ... visible area of the pane you're looking at? Is that the proposal?)
-
The primary benefit is that all the code is in one file.
The primary drawback is that all the code is one file.
Filed under: I'll be here all week... try the veal.
-
@anotherusername said in What are the benefits/drawbacks of keeping all the code in one file?:
The primary benefit is that all the code is in one file.
The primary drawback is that all the code is one file.
Filed under: I'll be here all week... try the veal.
Don't forget, devs become experts in merge conflicts!
-
A couple years ago, the company I work for had hired a full-time game developer for an ultimately doomed project, and at one point I showed him my side project. He was astounded that I had separated the source code into hundreds of files (or, roughly one .cpp/.h per class). It seemed excessive, in his view. Then again, he probably had never worked on a team larger than a couple people.
-
@raceprouk said in What are the benefits/drawbacks of keeping all the code in one file?:
Benefits: None.
Not quite true. It can enable more inter-procedural optimisation without requiring turning on disruptive stuff like LTO. But if someone's doing that, they can usually find ways to break the code into multiple files for editing; a build step to assemble the results into a single file for a prod/release build is easily made if the code has been written with doing that in mind.
-
@shoreline said in What are the benefits/drawbacks of keeping all the code in one file?:
@dkf said in What are the benefits/drawbacks of keeping all the code in one file?:
tightly-defined theme to each file
You mean I should "separate" the "concerns" of code into specific files?
That sounds suspiciously like sourcery.
FTFY
-
@bugmenot said in What are the benefits/drawbacks of keeping all the code in one file?:
arbitrarily many source panes open on the same file, with separate save semantics
How the hell would that work? What happens if you scroll two windows so they're looking at overlapping regions, and hit save in one of them?
-
@dkf quantum saving, it's both saved and not saved until you try to run whatever code it is.
-
@blakeyrat The same was (mostly) true of Access when I was
suffering throughworking in it back in the mid-1990s. You could have either one module, with everything - database, forms, code, etc. - or separate the code and other auxiliary material from into one database file which then used another one with the actual data as a slave module - and that was it.This was a large part of what led to the "Test No Software" bullshit, because it made it damn near impossible to share code between the six or seven different versions of the main product, hence the practices of copypasta coding and coding by exception couldn't be entirely avoided even if the lead dev hadn't been inclined to use them to begin with.
As the article states, I tried to convince them that they should hoist as many of the common code sections as possible and re-work them into a set of VB modules that the Access part could call (which would still have been horrid but at least it would've been an improvement) but they insisted that there wasn't time to do that.
I understand that it actually was done later, but not until after their main (and sole) competitor in that niche bought the company out anyway. The fact that this purchaser went under a short while later tells you how good the new management was, even compared to "Scott Slocum" (I'll keep his real name hidden though I can't imagine it matters now).
-
@dkf said in What are the benefits/drawbacks of keeping all the code in one file?:
@bugmenot said in What are the benefits/drawbacks of keeping all the code in one file?:
arbitrarily many source panes open on the same file, with separate save semantics
How the hell would that work? What happens if you scroll two windows so they're looking at overlapping regions, and hit save in one of them?
-
@dcon said in What are the benefits/drawbacks of keeping all the code in one file?:
@vault_dweller said in What are the benefits/drawbacks of keeping all the code in one file?:
It's easier to understand the folder structure of the source code
Our previous lead absolutely forbid that. So we have 1606 cpp/h files in one directory. But the solution has folders! (where in the solution is x.cpp located? Fuck if I know. <opens vcxproj.filter file in editor, search, ah ok>)
Doesn't the solution explorer let you search referenced files right there in that window? I know it's there in 2015....
-
@shoreline said in What are the benefits/drawbacks of keeping all the code in one file?:
I'm trying to keep an open mind.
Yes, you should be open to options for punishment.
-
@dragnslcr said in What are the benefits/drawbacks of keeping all the code in one file?:
@shoreline said in What are the benefits/drawbacks of keeping all the code in one file?:
@dkf said in What are the benefits/drawbacks of keeping all the code in one file?:
tightly-defined theme to each file
You mean I should "separate" the "concerns" of code into specific files?
That sounds suspiciously like sourcery.
FTFY
F*ckin' brits/DW readers.
@dkf said in What are the benefits/drawbacks of keeping all the code in one file?:
@bugmenot said in What are the benefits/drawbacks of keeping all the code in one file?:
arbitrarily many source panes open on the same file, with separate save semantics
How the hell would that work? What happens if you scroll two windows so they're looking at overlapping regions, and hit save in one of them?
What an excellent question.
@boomzilla said in What are the benefits/drawbacks of keeping all the code in one file?:
@shoreline said in What are the benefits/drawbacks of keeping all the code in one file?:
I'm trying to keep an open mind.
Yes, you should be open to options for punishment.
Aren't I being punished enough?
...
I heard it!
-
@shoreline said in What are the benefits/drawbacks of keeping all the code in one file?:
@dragnslcr said in What are the benefits/drawbacks of keeping all the code in one file?:
@shoreline said in What are the benefits/drawbacks of keeping all the code in one file?:
That sounds suspiciously like sourcery.
FTFY
F*ckin' brits
Wrong.
DW readers.
Bullseye.
-
@shoreline said in What are the benefits/drawbacks of keeping all the code in one file?:
DW
OK, all I can find is DW Sports, Dear Wife, or Arthur's little sister. None make sense, so I'm going to assume it's Dusty Willy
-
@jaloopa It's Discworld.
-
@scholrlea said in What are the benefits/drawbacks of keeping all the code in one file?:
The same was (mostly) true of Access when I was
suffering throughworking in it back in the mid-1990s. You could have either one module, with everything - database, forms, code, etc. - or separate the code and other auxiliary material from into one database file which then used another one with the actual data as a slave module - and that was it.Hey, I resemble that. We use Access here and we have one big behemoth database with most of the data and a bunch of VB application-level code that munges it as it's being entered.
On Access '97, it actually wasn't too bad -- just copy the database off the network share folder to my desktop, edit it, and move it back to replace the original. People were using it at the time, but this didn't cause problems (surprisingly enough). Then we upgraded to a newer version of Access and every time I'd have to edit it, we'd start getting messages about the database being in an inconsistent state shortly thereafter.
What I ended up doing was duplicating the database, then replacing all of the tables in one with linked tables to the other database. Of course, that just meant I had two database files on the network share folder that couldn't be edited because they were in use. So I had to get more creative.
Now, the front end portion checks its path when it opens, and if it's running from the network share, it copies itself to the
%userprofile%
folder, then closes and relaunches itself from there. If it's running from the%userprofile%
folder, it checks for an update: it compares its date modified to the date modified on the copy in the network share; if they don't match, it closes, overwrites the copy in%userprofile%
with what's in the network share, and relaunches. It also performs the check for an update each time you return to the application's "main menu" form.I still can't modify the underlying database that all the tables are linked to without tracking down everyone who's using it and getting them to exit, but I can at least freely modify the application-level code, and everyone's local copy will update themselves automatically in fairly short order. If they need to force it, they can close it and reopen.
-
@tsaukpaetra said in What are the benefits/drawbacks of keeping all the code in one file?:
Doesn't the solution explorer let you search referenced files right there in that window? I know it's there in 2015....
2017 too. But not 2010 (not that I see...)
-
@bugmenot said in What are the benefits/drawbacks of keeping all the code in one file?:
- essentially replicate what
text filesindices were supposed to do in the 70's, butpacked inmanually added to a single file
FTFSSDS
- essentially replicate what
-
@anotherusername said in What are the benefits/drawbacks of keeping all the code in one file?:
replacing all of the tables in one with linked tables to the other database
If you had used links to an actual SQL database, the problems you mentioned would have been virtually eliminated [yes, some other ones would have been introduced]
-
@thecpuwizard not really. Yes, I'd be able to modify the design of the underlying database, then, but that's really not that much of a problem anyway -- I rarely ever need to do that. It's usually just the VB code that needs to be changed.
There'd still be the main problem, which was how to modify the application layer; it couldn't be modified without exclusive control of it if it was still a network shared Access file, so it would've required finding everyone who had it open and having them exit. I did briefly think about trying to rewrite the whole thing in PHP, which would've eliminated that problem, but quickly decided that it wasn't worth the effort. What I ended up doing solved it well enough.
-
@shoreline it compiles faster
-
@wharrgarbl said in What are the benefits/drawbacks of keeping all the code in one file?:
@shoreline it compiles faster
But it's also bloody hard to build in parallel.
-
@shoreline said in What are the benefits/drawbacks of keeping all the code in one file?:
I am currently working on a piece of software where they have 16k LoC in a single file, which people develop in. This is source. Not concatenation/minification/transpilation/compilation/gentrification.
Uhm... it's easier to delete the whole project that way?
-
@scholrlea said in What are the benefits/drawbacks of keeping all the code in one file?:
@shoreline said in What are the benefits/drawbacks of keeping all the code in one file?:
I am currently working on a piece of software where they have 16k LoC in a single file, which people develop in. This is source. Not concatenation/minification/transpilation/compilation/gentrification.
Uhm... it's easier to delete the whole project that way?
Which should probably be done at this point.
-
@scholrlea said in What are the benefits/drawbacks of keeping all the code in one file?:
@shoreline said in What are the benefits/drawbacks of keeping all the code in one file?:
I am currently working on a piece of software where they have 16k LoC in a single file, which people develop in. This is source. Not concatenation/minification/transpilation/compilation/gentrification.
Uhm... it's easier to delete the whole project that way?
We have a winner.
-
@shoreline said in What are the benefits/drawbacks of keeping all the code in one file?:
@scholrlea said in What are the benefits/drawbacks of keeping all the code in one file?:
@shoreline said in What are the benefits/drawbacks of keeping all the code in one file?:
I am currently working on a piece of software where they have 16k LoC in a single file, which people develop in. This is source. Not concatenation/minification/transpilation/compilation/gentrification.
Uhm... it's easier to delete the whole project that way?
We have a winner.
It's simultaneously a benefit and a drawback! Who could ask for more? :D
-
@scholrlea said in What are the benefits/drawbacks of keeping all the code in one file?:
Uhm... it's easier to delete the whole project that way?
-
@blakeyrat said in What are the benefits/drawbacks of keeping all the code in one file?:
That only works if the JavaScript happens to be running in a DOM environment like a web browser.
If it's something like ActionScript in Flash or JScript in WSH, nope... there's no such thing as a <script> tag.
In other news, shake out those "If JavaScript MUST BE WEB BROWSER!" brainworms. JavaScript was used in all kinds of places for decades, most of which were not web browsers.
...please don't encourage it!