Live data from Hacker News

TerrariaClone – An incomprehensible hellscape of spaghetti code

github.com

91–100 of 289 posts

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#91

I wonder how hard it would be to write a program to automatically refactor code like this into something reasonably clean. My intuition thinks it should be difficult but possible... and extremely useful.

There are linters which do a bit of this, but they only cover the lints they have rules for. I'm pretty sure no one has a rule for "all loop indices declared as class members" because no one writing code of this quality has yet used a linter. Many issues in this code-base are not tractable at all for automated repair: how are you going to rework thousands of line long methods into well-factored classes and methods?

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#92
I would love if we could get together as a community, take a project like this, and use it as an example for what a little refactoring can do.

As a cooperative endeavor it should be doable, but a competition would be more fun, though I can't imagine how you'd judge such a thing.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#93
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 swear I know a guy who would have done this. I have worked with him. I have cleaned up his code. I have asked him to clean up his code and been yelled at in response.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#94
post #43
post #37

Earlier quoted context omitted.

Writing code in spare time, not to mention 11,000 lines of it, already sets any high schooler (or any beginning programmer) apart from the majority of peers. It's shocking how little students in "AP" computer science courses actually end up doing, and how few do anything outside of class. Given the choice between interviewing a student who had produced nothing but verbiage and one who had produced TerrariaClone, I wo…

I had a rather unique AP Computer Science high school experience a number of years ago. The AP class was mainly a self or group study class inside of a lower level programming class. We didn't get as much directed study, but we basically were allowed to chose projects that interested us and spent a lot of time developing them and getting help, iterating, figuring it out. We ended up doing only OK on the AP exam, but…

Comments like this kill me a little on the inside, I can't stand having real work devalued for the sake of contrived assessment criteria.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#97
post #37

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…

Writing code in spare time, not to mention 11,000 lines of it, already sets any high schooler (or any beginning programmer) apart from the majority of peers. It's shocking how little students in "AP" computer science courses actually end up doing, and how few do anything outside of class. Given the choice between interviewing a student who had produced nothing but verbiage and one who had produced TerrariaClone, I wo…

When I was 12 (and computers weren't really a thing) I wrote an RPG. In ZX Spectrum Basic. It wasn't great (let's be honest, TerrariaClone sounds like the Mona Lisa in comparison), but it worked. I didn't realise at the time that this weird little hobby of mine would stick me right at the front of an emerging field. Nor did my family who thought I should be doing.. almost anything else. I got ridiculously lucky, all because I started writing bad computer games in high school.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#98
post #80
post #76

Earlier quoted context omitted.

One of the things it took me a while to intellectualize is that 'you' a year ago is a very different person from 'you' today. Given enough time, maintaining a much larger body of code than a single person can reasonably handle, you're going to have disagreements with yourself without even realizing it.

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).

I always think when this happens, "At least I must be improving."

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#99
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...

A textbook example of a quasi-class: http://www.idinews.com/quasiClass.pdf

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#100
post #63

Earlier quoted context omitted.

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 swear I know a guy who would have done this. I have worked with him. I have cleaned up his code. I have asked him to clean up his code and been yelled at in response.

Pretty sure we all do. The constraints under which he was operating to create the mess I took over I understand well, and I do not blame him for the end result.

He is a manager now, though, not a day-to-day programmer ;)

Post reply on HN