Live data from Hacker News

TerrariaClone – An incomprehensible hellscape of spaghetti code

github.com

131–140 of 289 posts

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#131
post #12

Earlier quoted context omitted.

Truthfully - I wouldn't call it spaghetti code. I think of spaghetti code as way to many abstractions (AbstractEntityFactoryFactory). This code has the opposite problem - needing more abstractions - which is the easier direction to move.

Global state causes code to be spaghettified. Having worked on several code bases that qualify as spaghetti code, the hallmark trait is that the execution flow is wound back around itself many times, like noodles in a bowl of spaghetti, in a way that's not easy to trace. You may have nice abstractions or none. You may have deeply nested type hierarchies or a seemingly nice flat structure. You may be using an IoC cont…

That’s sort of what I thought of. Is soon as I read a bit about having global variables at the top of every file I am mediately remembered how I used to program BASIC when I was first trying to learn it.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#132

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…

Give yourself permission. I have a GitHub repo called "junkcode" for this very purpose - sometimes projects are promoted out of there, sometimes not.

I like that idea a whole lot. I tend to just throw stuff on GitHub. Some is prototypal. Some is polished. Some is just terrible in every way. Your approach seems better, and is aptly named.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#133
post #63
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 disagree. I inherited an app that I'm maintaining that was written by one person over ~12 years. When requirements were added, he just cloned the app and started making the changes so the new app would meet the requirements. Repeat 2 more times, and you get to now, where there are 4 similar but not identical versions of the same code base, with inconsistently applied fixes to various bugs. All 4 still need to work…

I think that's a perfectly good way to develop a bunch of somewhat-similar apps for different customers. As long as you refactor all the time.

If you don't then you are basically one developer doing a serial simulation multiple developers miscommunicating in parallel.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#134

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…

Give yourself permission. I have a GitHub repo called "junkcode" for this very purpose - sometimes projects are promoted out of there, sometimes not.

That's a pretty good idea, actually. Sometimes I throw a repo up to play, but take it down out of insecurity...

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#135

Earlier quoted context omitted.

Give yourself permission. I have a GitHub repo called "junkcode" for this very purpose - sometimes projects are promoted out of there, sometimes not.

I like that idea a whole lot. I tend to just throw stuff on GitHub. Some is prototypal. Some is polished. Some is just terrible in every way. Your approach seems better, and is aptly named.

I can't take credit for it - the idea came from Andrew Tridgell - https://github.com/tridge/junkcode

http://samba.org/ftp/tridge/talks/junkcode.pdf%E2%80%8E

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#136
post #82

When I first started programming (this was in C++), I decided that the obvious optimisation was to declare all these redundant local indices i,j,k as globals. Then the program won't need to make all this redundant crap! Of course that led to absurdly subtle bugs that only occasionally showed up since whenever I called a function which had a loop in it from inside of another loop, I would use i as the index for both l…

I'm sure it would have lead to problems, that's just one of the examples of beginner mistakes with the code. That's kind of the point of this post, for the author to poke fun at themselves for the number of newbie mistakes they made.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#137
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…

Given the relative size of the function and typical memory, I suspect that the issue the author ran into was actually the JVM's 64KB limit on the bytecode size of a compiled function.

https://stackoverflow.com/questions/17422480/maximum-size-of...

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#138
When technical debt gets so large that you go bankrupt ( quit the project ). I did this with an actionscript game. Then an html editor. I did not know what I was doing. I looked back at the code and decided that starting from scratch would be much faster than refactoring what existed there.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#139
post #90

Earlier quoted context omitted.

I'm sure there was a good reason for that.

I'm not so sure. In the readme he says there are over 500 cases of "unnecessary boxing."

Raise your hand if you were excited when you heard Java 1.5 would introduce autoboxing.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#140

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…

watching the creator of The Witness do some live stream coding made me realize this too. he just typed the convenient thing he needed at each moment and didn't try to abstract away the mess. just forged ahead.

Oh yeah, Jonathan Blow's coding videos show an amazing exercise of pragmatism: https://www.youtube.com/user/jblow888/videos
Post reply on HN