Live data from Hacker News

TerrariaClone – An incomprehensible hellscape of spaghetti code

github.com

191–200 of 289 posts

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#191
post #108

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…

As I had to work more with teams and then supervising teams I changed the abstractions I value from when I was programming solo: Now I care less about my project's function than the structure of the team. There is a saying that any complex project will end up mimicking the communication structure of your organization. I must confess I thought it was silly until I realized it happened to us. I now favor code that has…

You're talking about Conway's law.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#192
post #163
post #52

Earlier quoted context omitted.

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

Maybe those are stubs the author intended to do something else with later?

Original author here.

I can confirm that the actual reason is that at the time I thought typing "print" instead of "System.out.println" was a great idea.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#193

The best thing about this is the open issue claiming it's "Too much like the real Terraria source code." [1] :) This bring back a lot of memories. Way, way back in the day i wrote a clone of Battle City [2] in XNA with a half-decent AI. I had intentions to learn and use some OOP patterns. I ended up with a handful of monstrous classes and generally a clusterfuck of spaghetti code. But... i learned a lot about AI and…

Holy shit.

Be sure to read the issue. It turns out it's not really a joke - someone in the know points out that Terraria's code is basically the same quality, if not worse...

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#194
post #19

Earlier quoted context omitted.

Important to note is that this code is not the source code, but rather was generated by dotPeek, a C# decompiler, as mentioned in the repo's README: https://github.com/csnxs/Terraria/

Variable names and comments are lost, but the overall control flow structure of decompiled Java and C# code closely matches the original.

Still - does that decompilation roll back any kind of array unrolling C# compiler may be doing (assuming it's doing it)? If not, it could explain those long chains of if/else seen in the decompilation. Maybe they're arrays of constants in the real code?

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#195

The real Terraria code isn't much better. Here's their 3MB [decompiled] NPC.cs: https://raw.githubusercontent.com/csnxs/Terraria/67de21a27e1... They had serious problems implementing multiplayer because they had to synchronize objects with 50KB of state every frame.

This looks as if this was a compile target, not the source code. HitEffect is a quite the function. This reminds me of working on CDDA[1] before many of the refactors hit. CDDA is an interesting case, it stemmed from a situation similar to the original post (one person project, embarked upon it before knowing how to do so). It was a complete mess of macros, spaghetti code and data and code living happily side by side…

It was, or still is? Also, are you still working on it?

I'm currently having lots and lots of fun playing this game (experimental builds). It's pretty much halfway there to Dwarf Fortress...

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#197
post #190

Earlier quoted context omitted.

I believe so too, but it's not even that much a function of team structure. A proper design will have lots of places that are mostly self-contained at various levels of abstraction - more than people you have in your team. I believe work should be distributed among those boundaries, because it lets people agree on the interfaces and work mostly in isolation. Also, most of the time, small self-contained units of code…

Re: 0 sometimes I wish I could just be paid to read and understand code.

Unless one's in constant crunch mode, just hammering out whatever crap that makes tickets disappear, there's always time for that in programming. Often it's just jumping into a library method and looking around instead of opening a new browser tab and typing "how XYZ works stackoverflow".

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#198
post #61

Earlier quoted context omitted.

I will try this tomorrow, I am pretty sure dotPeek can recognize and output else if. Might be a coding style option though.

Wouldn’t “else if {“ and “else { if” compile to identical bytecode?

Sure, but the decompiler can choose to always decompile to "else if {", which is more readable and more likely to match the original source code.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#199
post #89
post #80

Earlier quoted context omitted.

Absolutely. When I stumble upon some code in my full time codebase that I find distasteful, my first thought is "what idiot did this". git blame and sure enough, it's me. Past me has been and always will be an idiot as far as present me is concerned (with some infrequent exceptions).

If you like comic books where the hero has to travel in time to fight himself, you'll love programming.

I want this on a t-shirt.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#200
Reminds me when I first stumbled upon a book on BASIC at my elementary school library, then got ambitious and tried to write my own Galaxian-ish game. Started with a whole screen with all the enemies and stuff, prompted for an input, and started trying to map out every single possibility.

Needless to say, I gave up very quickly and convinced myself that this "programming" thing was way too hard. Didn't even start to dabble in it again until high school (and that was mostly a bunch of mucking about with VB6 in Word/Excel).

Post reply on HN