Live data from Hacker News

TerrariaClone – An incomprehensible hellscape of spaghetti code

github.com

51–60 of 289 posts

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#51
post #25

I think true spaghetti code requires teamwork. I mean that seriously. You need at least 3 people all with different incomplete and incorrect mental models trying to modify the same codebase at the same time.

I agree. But then again, I'm like a completely different programmer than I was a few years ago, and even more different than I was years before that. I've got some long running personal scripts and projects I tweak every so often, and the end result is pretty much the same. "What the hell was I doing here? Whatever... I'll just add a bit of code and get it working. Done."

That describes my experience with some of my GitHub projects fairly accurately.

Actual commit I did a few days ago:

> Begin rewrite of rewrite of rewrite

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#52
post #9

I love DoubleContainer: https://github.com/raxod502/TerrariaClone/blob/master/src/Do... which is fortunately only used in a comment here: https://github.com/raxod502/TerrariaClone/blob/9ea04b15add48...

My favorite part is the overloaded print methods: https://github.com/raxod502/TerrariaClone/blob/master/src/Te...

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#53

I'd actually try to recruit raxod502 at the high-school senior level. It certainly shows passion and commitment. You just need to grok the higher level abstractions. And may in the end even find your "spaghetti" version is actually more performant at run time ;) The thing is you sort of need to write like this for the first draft of your first game. And Terraria is pretty ambitious. Considering most people struggle w…

> And may in the end even find your "spaghetti" version is actually more performant at run time

not with those O(N^2) loops it ain't

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#54
post #36

> The TerrariaClone.init() method, which is over 1,300 lines long, actually grew so large that the Java compiler started running out of memory trying to compile it! Seems surprising, 1.3kloc doesn't feel that big in the scale of things. I wouldn't be surprised if some of the methods at $work would be on the same scale, and it compiles just fine (relatively speaking..). And based on quick scroll-through, there isn't r…

In one of my previous jobs there was ClassSomething1, ClassSomething2 until 5 just because java can't have more than 65535 methods in a class..

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#55
This reminds me of the C# source code for DRAGON. Its code was actually much worse, because the creator wasn't aware of things like loops or method definitions (the main game loop and class appear to have been generated by a framework).

The C# code is here, and it works well enough that you can buy it on Steam, apparently: https://gist.githubusercontent.com/alessonforposterity/832da...

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#57

This makes me sad. Not because of the code quality, but because it makes me think of all the games I used to write back in middle school that are now lost to the swirling sands of time. The youngins don't know how good they have it with github!

Your comment reminded me of a game (maybe the only one) I wrote in middle school, on a TRS-80 Color Computer (I think 4K, although maybe I had the 16K upgrade by the time I wrote the game). I wrote it in basic & saved it on some cassette tape... random blocks of one color on the screen, and you are a block that starts at the bottom and you use arrow keys to avoid the blocks as you are thrust upward. (I guess it was basic in more ways than one). I might have added a 3rd color block that gave you points if you hit those.

I wonder if I could even write it now - even at low resolution? My limited scripting is now systems-oriented, the tiny bit of UI stuff takes me forever & I find HTML & JS way more complex than basic ever was. (Don't misunderstand, I think my python scripts that interact with various AWS services, postgres, etc are just fine and don't take me long to write or maintain, its just the whole graphics world I never latched onto...)

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#58
post #45
post #23

Earlier quoted context omitted.

Decompiling .NET or Java binaries usually yields code very close if not identical to the original source code, at least unless an obfuscator was used but that seems not to be the case here. Chances are very good the original source code looks almost exactly like that code, maybe with some additional comments.

Mind you, a lot of Java 5 and later features like generics, switch on Strings, Iterable-based for, etc., are syntactic sugar implemented in the compiler, not part of Java bytecode, so those features don't decompile well.

I am not sure about Java decompilers, but the .NET decompilers I have used all perform pattern matching in order to detect and reverse language features implemented with compiler transformations.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#59
This makes me miss my early days of programming, where no code was too verbose or horrible to stop me from progressing towards my goal, no matter how misguided I was. Nowadays I'm distracted by the first hint that there might be some better way, and all progress stops. I think I'm just beginning to recognize this, and maybe one of these years I'll learn to recognize when the right abstraction is really important and when it's not worth sweating the small stuff.
Post reply on HN