Live data from Hacker News

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

austinhenley.com

91–100 of 346 posts

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

#91

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

Code could be well-modularized in one single file, of course. But we don't have the tools to write code like that (editors and languages basically).

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

#92

That's me when I use languages that don't support circular imports. Can't have circular imports if everything is in the same file. Taps head.

Just in passing, generally you can break circular import by isolating the coupling that triggers the circle chain in a file dedicated to that. Bonus : each coupling use case gets to be explicit

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

#93

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.

I've sadly come to realize (after witnessing on many projects) that there's a pattern that goes like this: * Team A writes code quickly. Not bad code, really, but they take shortcuts everywhere they can. They don't have the strongest tests, they don't generalize for all the known use cases, etc. Their code goes to beta and gets users and makes progress. * Team B deliberates and deliberates. They try to avoid taking s…

I kinda agree on this, but not for the implicit reason you're probably thinking of.

Just starting and doing it is just unreasonably effective because very few projects actually need novel solutions - most are just fine with off-the-shelf hacked together solutions.

Thinkers are required if the software is actually groundbreaking new work. Almost everyone's work on this forum probably isn't that however (mine included), which is why I agree with your sentiment

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

#94
Most of the comments here seem to be focusing on Austin's reference to it as an 11k line of code file, but if you read the article it sounds a lot more like it's both an 11k line of code file and an 11k line of code procedure. That is, that there are no sub-procedures, just one straight execution through the whole thing. If you've only encountered large-ish source files like this but with reasonable sets of functions inside, that's a far cry from finding an 11k line of code procedure itself. The former is often justifiable (though perhaps a stretch), the latter is almost never justifiable. It's just garbage.

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

#95

> 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 subse…

I'd wager they did break those other forms, the whole thing had its own long list of bug reports per the writeup. They just didn't break it for themselves.

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

#96
post #84

Earlier quoted context omitted.

I've sadly come to realize (after witnessing on many projects) that there's a pattern that goes like this: * Team A writes code quickly. Not bad code, really, but they take shortcuts everywhere they can. They don't have the strongest tests, they don't generalize for all the known use cases, etc. Their code goes to beta and gets users and makes progress. * Team B deliberates and deliberates. They try to avoid taking s…

+1 I had a lot of trouble trying to explain this to juniors. The most important things is to have code that is easy to refactor when you know what you're doing (i.e. everything is working properly). Juniors I worked with had a nasty definition of a pretty code being split into a hundred files, each no longer than a screen, and each function no longer than 5 lines. The onboarding of new devs to such code was way worse…

> The most important things is to have code that is easy to refactor

Very true.

I'll just add that another most important thing is to actually take time to refactor, even when things are busy.

I spend maybe 1/3 of my time refactoring, and that feels good.

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

#98

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.

I've sadly come to realize (after witnessing on many projects) that there's a pattern that goes like this: * Team A writes code quickly. Not bad code, really, but they take shortcuts everywhere they can. They don't have the strongest tests, they don't generalize for all the known use cases, etc. Their code goes to beta and gets users and makes progress. * Team B deliberates and deliberates. They try to avoid taking s…

I don’t think this dichotomy is helpful. I’m presently working at a startup that’s trying to dig itself out of a hole created by the first CTO, who in doing things “quickly” created an MVP so buggy, inefficient, crash-prone, and unmaintainable that we can’t retain customers or engineers. As always, there’s a balance to be struck, and ways to operate quickly that don’t sacrifice quality too much.

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

#99
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 have seen that in real code. No kidding.

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

#100

i used to work on 40-50k line files with one function and a bunch of gotos in perl, in a multi billion dollar company its fine you just binary search your way into it, put print "AAAA" in the middle, see if its printed, then put it in the half of the half and try agian. emacs couldnt even find the bracket ending of the if condition (not the block, the condition..), have you ever seen if conditions(again, not the bloc…

This is the right attitude, sometimes you really do need the duct tape approach.
Post reply on HN