Live data from Hacker News

A project with a single 11,000-line code file

austinhenley.com

61–70 of 346 posts

Re: A project with a single 11,000-line code file

#62

It really speaks to the state of software engineering when there are ample comments here defending this practice. This is virtually indefensible in my book, as it screams technical debt and strongly suggests that there are much deeper issues hiding in that codebase. Personally I would not be willing to work on it without first addressing those issues.

It speaks to the state of software engineering that people are complaining about file length, instead of something meaningful like cyclomatic complexity.

A 10k single line program can be easier to understand and better organized than an overly abstracted mess strewn across multiple files, but which checks all the "best practice" checkboxes.

Re: A project with a single 11,000-line code file

#63
post #50
post #47

Earlier quoted context omitted.

You sound like you should read this: [removed] apparently jwz decided not to be linked from here :/ there's an archive.org link below.

Heads up: jwz.org redirects Hacker News visitors (via "Referer") to an image of a slightly-hairy testicle sitting inside an egg cup. So maybe don't click the link at work.

That’s friggin’ hilarious. What a boss.

Re: A project with a single 11,000-line code file

#64
post #38

If well done, single file projects are not bad. They save a lot boilerplate code. It is also easier to find things, since it is all in the same file. EDIT: I'll go even further. Programmers who don't like long files are probably using the scrollbar to navigate around the file. Vim saves me from that bad habit.

What programming language requires 'a lot' of boilerplate code to use multiple files? That sounds awful. I don't think the argument for things being easier to find goes up either, with a tool like grep.

Perl XS (the system used to interface with C) requires module == file, so if you have a particularly large module then it just has to live in a single file. Here's one:

  $ wc -l perl/lib/Sys/Guestfs.xs 
  11930 perl/lib/Sys/Guestfs.xs
Worse still, this expands to C which can be large and takes a noticable time to compile:

  30019 perl/lib/Sys/Guestfs.c

Re: A project with a single 11,000-line code file

#65
> Once I dared to clean this up and reuse the authentication response, but it broke everything.

Yet! Those non-programming people somehow managed to add their little requirements over the years, without breaking the other forms?

There is probably more to the story. Like that, I suspect, users who needed to produce a certain form probably had private, years-old copies of the program that they used, impervious to subsequent changes.

Re: A project with a single 11,000-line code file

#66
post #9

That beats the 1000 lines inside a single if {} block that I once found. (The conditional in that if {} always evaluated to true).

Lol, reminds me of the meme: var a = true; if(a == true) then return true; else if(a == false) then return false; Or something like that.

i hate to say that I've definitely written code like that. not any time recently, thankfully (at least I think)

Re: A project with a single 11,000-line code file

#67
post #38

If well done, single file projects are not bad. They save a lot boilerplate code. It is also easier to find things, since it is all in the same file. EDIT: I'll go even further. Programmers who don't like long files are probably using the scrollbar to navigate around the file. Vim saves me from that bad habit.

What programming language requires 'a lot' of boilerplate code to use multiple files? That sounds awful. I don't think the argument for things being easier to find goes up either, with a tool like grep.

You don't need to go far. In C, function prototypes in header files are boilerplate ;)

Re: A project with a single 11,000-line code file

#68

So afraid to write bad, spaghetti code, I ended up writing no code at all. This thread made me realize that it's better to have a working profitable project with bad code, than a perfect unfinished project, with meticulously chosen design patterns. Afraid of being judged for bad code, I could not start until I had the right architecture. I'm glad I read this. This is developers therapy.

[deleted]

Re: A project with a single 11,000-line code file

#69
Well, this is not necessarily a bad thing. If it was approachable by a non-IT person in HR, and business rules could be updated without contacting IT and waiting, then more power to them. I have seen this sort of thing developed as a coping mechanism because the official IT team could not be used, either due to time, cost, priority, or whatever. Also, even being in IT, 1 multi thousand line file can be a lot more manageable to work in vs. a dozens of smaller files where it's not clear where to look without being in an IDE.

Re: A project with a single 11,000-line code file

#70

I don't get the obsession with file length. What's the benefit of having 100 files with one 50-line function per file, over having a 5000 file with 100 functions? Obviously not counting extreme cases where the file size would break some editors' buffers

Ability to structure your code base hierarchically

Ability to search through your codebase by file name

Ability to hide irrelevant information and expose a higher level API through private functions

Post reply on HN