Live data from Hacker News

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

austinhenley.com

101–110 of 346 posts

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

#101

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…

Be Team C.

Team C works like team A. However every time a feature ships, someone who knows that feature well immediately refactors the relevant code to remove the prototype scaffolding. When code becomes static, an expert adds good quality comments. When a bug is found, it is recreated in a regression test prior to being fixed for good.

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

#102
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 practices" at all. Yet, not surprisingly, it worked pretty well and was actually not difficult to modify --- Ctrl+F would easily get you to the right place in the code.

I guess the moral is, never underestimate what determination and creativity can do, and always be skeptical when someone says there's only one best way to do something.

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

#103

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…

It's impossible to refactor spaghetti code without a comprehensive test suite. But you can do it with a test suite - I've done it with large code bases.

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

#104

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

Personally I find it much more difficult to keep n places in one giant file in my head than I do n individual files.

We have a few multi-kloc legacy monsters where I work and I quite often completely lose my place when working on them (and, by association, my train of thought), even though they’re actually structured somewhat reasonably.

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

#105

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…

There's a YouTube video about beginner musicians vs intermediate vs advanced.

The beginner uses simple chords

The intermediate uses advanced chords, crazy fills and runs and riffs.

The advanced uses simple chords

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

#106

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

Personally I find it much more difficult to keep n places in one giant file in my head than I do n individual files. We have a few multi-kloc legacy monsters where I work and I quite often completely lose my place when working on them (and, by association, my train of thought), even though they’re actually structured somewhat reasonably.

I had this problem until I found an editor that had outlining as it's core design paradigm. Now, with the outline always visible, it's _really_ easy to navigate any length file.

Unfortunately, at one point I got so used to navigating with the outline that I ended up making a 1500 line function in C (I was an even worse C programmer then than I am now). Because of the outline, I could read and follow it easily, but anyone with a different editor was royally screwed :-(

If you're interested, the editor is LEO (http://leoeditor.com/) it's been mentioned on HN a few times

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

#108
I can beat that.

One of my first jobs was as a maintenance programmer for a 100KLoC (or more) single-file FORTRAN IV (1970s vintage) application (a proto-email server).

Three-character variable names, no documentation, and having been stepped on by every junior programmer that went before me.

My best debugger was a Ouija board.

The original author was a ringer for Donald "Duck" Dunn. Interesting chap.

It taught me the value of writing good code.

It sucked.

It was great (because of the lesson learned).

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

#110
post #29

The payroll check printer for my employer was once a couple thousand lines that generated raw PCL to be sent to a LaserJet that used magnetic toner to produce checks that had a working MICR number. It was rendered into spaghetti by multiple GOTOs that jumped to helpful labels like "666", and calls into other helper programs to generate more PCL that did things like change fonts and draw graphics. Of course none of it…

Reading your process I have that stereotypical TV series image in my mind of a person so deep into the subject matter that plaster every wall with notes and pull string all across the room at head height to hang up ever more notes kinda like that one NCIS episode (S8 E6 "Cracked"): https://img.sharetv.com/shows/episodes/standard/616591.jpg (although that image is only a small part of that whole view).
Post reply on HN