Live data from Hacker News

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

austinhenley.com

171–180 of 346 posts

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

#171

I remember many years ago coming across a reimplementation of the server side for a popular MMORPG of the time, reverse-engineered from the client (which was Flash) by what was likely a teenager --- it was over 100k lines in a single file, written in Visual Basic. Global variables everywhere, short names, and not even indentation. All the account data was stored in flat files, there was no actual DB. No "best practic…

Ironically, this is a description of hacker news itself. https://github.com/shawwn/arc/blob/arc3.1/news.arc (HN has indentation, though.) It’s important to realize that this is good design. It’s hard to separate yourself from the time you live in, but the rewards are worthwhile.

This is a good point, but there's also a key difference.

There's a big difference between "code being in one file" and "code being in one function." It sounds like the OP had something reasonably close to "one function," whereas the HN code has a lot of (what appear to be) small well designed methods.

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

#172

Earlier quoted context omitted.

Try debugging a single 10k loc file versus fifty small modules where each takes care of a distinct part of the logic.

But what's the difference between file1.c ... file50.c vs cat file*.c > onefile.c?

I imagine the 50 files have meaningful names. Just kidding, no-one knows how to name anything.

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

#174

Back in the days at Zynga, there was this ritual that new members of the STG (Shared Tech Group, which developed the game engine stack) had to try to refactor the road logic code. Suffice it to say, it's a 28k LOC file that was so bad, it could even hold up in court as evidence that a South American company stole the code of Zynga's -ville games. We could reproduce each and every single bug and its effects 1:1 in the…

[deleted]

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

#175
I encountered the QGSJET-II model which we used for modeling cosmic ray showers in the atmosphere. At one point I was asked about finding a way to parallelize the code, but the 17k+ line fortran file for the model, which I recall also included self modifying code, was too deep for an undergrad to penetrate.

https://gitlab.iap.kit.edu/AirShowerPhysics/crmc/-/blob/mast...

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

#176
Quote: "There was no test environment. If I made a change, I had to test it in "production"."

What year is this? 70's and mainframes? Because no way in hell you cannot, on large organization that had "Jeff in marketing", since 80's and PC's, duplicate the environment. Especially given this was used by almost everybody in the organization.

And once you're done duplicating the production, and create proper test environment, you can start actually refactoring and creating a beautiful app out of it instead of just "To this day I sometimes lie in bed wondering what could have caused this".

Conclusion - article's author is a whiner instead of a solver, no better than the ones before him that "copy and pasted at some point then later diverged"

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

#177

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…

https://news.ycombinator.com/item?id=19956614

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

#179
post #164

Earlier quoted context omitted.

Ironically, this is a description of hacker news itself. https://github.com/shawwn/arc/blob/arc3.1/news.arc (HN has indentation, though.) It’s important to realize that this is good design. It’s hard to separate yourself from the time you live in, but the rewards are worthwhile.

The only readability issue I have with that is the functions expected arguments. Add some types and I’d be very happy to work on it. I believe Facebook uses a single directory of files now as best practice? With the file names including namespaces. That was an HN comment from ages ago so could be wrong or misinterpreted.

pg's new lisp, Bel, has something close to typed arguments:

  (def add1 (x|int)
    (+ x 1))
http://www.paulgraham.com/bel.html

I've been implementing it for a couple years now, though not seriously till the past couple months. There are some interesting (and overlooked) ideas in Bel.

Bel is sort of the limit case of generality. For example, you might expect the "type" above to be a separate kind of object, the way that types are separate kinds of things in TypeScript.

But in fact, it's simply a function that receives the argument and can throw an error. So for example, you can do something like:

  (def positive (x)
    (if (
I just wish he'd solved keyword arguments as thoroughly as every other kind of argument. There are hints that it was always in the back of his mind. Though it's true he never needed them, so that's probably why he never made them.

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

#180

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

I think the problem in this case was that the entire file was the script that ran top to bottom. It’s not so much that the file was big, but that the function was huge and impossible to reason about.

I agree that obsessing over file length is it’s own kind of anti pattern. I have had colleagues who insist on putting every little thing in a different file and that is its own special kind of hell.

Post reply on HN