Live data from Hacker News

TerrariaClone – An incomprehensible hellscape of spaghetti code

github.com

101–110 of 289 posts

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

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

I had a similar experience in high school. I took a "Technology" elective class where most people were just playing Warcraft III because the teacher didn't really care what we did. I don't remember him actually teaching us anything.

A few of us spent the time working on our own real-time strategy game written in Java and using Anim8tor for 3d models. By the end of the year we had a map, artwork, and some network code to allow multiplayer. You could place buildings, select units, move, attack, etc.

My friend found the source on an old USB drive a couple years ago and we were able to get it running again. Some of the code was hilariously bad, but we were both impressed that we had been able to get that far and that it worked since we didn't really know what we were doing. Fun times :)

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#104

http://sohcahtoa.org.uk/kepler/tmoon.c Grunge C and huge comment block at start, compiles and works though. One day, I'll revisit this and have a think about data structures.

Wow, that indentation...

Yup. Was written about 20 years ago. I'm an amateur.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#105
post #58
post #45

Earlier quoted context omitted.

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.

At least the last time I used it (2015), IntelliJ's decompiler didn't.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#106

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…

It is often impossible to write code the first time anyways, just do it, realize your technical debt, and come back and refactor it when the better abstraction is more obvious (if any).

Ah, but try that in an interview and see what happens.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

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

It's particularly encouraging to see it posted with mistakes. Sure, it's a bit of a joke, but it's also an experience to learn and grow from. Reflecting on past projects is so rare that I think it might be the best indicator of a programmer who will continue to improve.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#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 a lot of independent modules that can have hacky inner code but that must have clear, explicit and preferably simple interfaces. The project's manager role is to design these interfaces and has the last work on their implementation.

This is a bit the Unix way. Every module has to do one thing (and optionally do it well). This allows veteran programmers who know all the subtleties of the programming language to collaborate with rookie programmers who may write okay-ish modules that we may have to rewrite later but that work well enough.

It also allows programmers, these very territorial beasts, to have their own little realms they control and where they are acknowledged. It helps non-tech managers understand who has to be assigned on different issues and evolutions.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#109
post #79

Earlier quoted context omitted.

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.

Thinking of video game, I think this is a good analogy: a lot of what you write in the beginning are just tools to your own program. I'm really talking about the lines in your code, they're structured so well that they will help forge more code in the middle and later parts of your code life. Like any good video game, if you produce good tools in the beginning to produce levels, modes, multi-player games, etc... then…

But you can go too far there. The Witness guy explained it like this: You need to do a breadth first search of your code. If you rabbit hole for weeks making the perfect level design tool before you have already made a working prototype of the game for example, you might then months later, as you build out the game, realize the level building tool you have made isn't really suitable.

As you start filling out the breadth of your design a time will come when you know an idea is going to work, and you have more knowledge to inform your tool.

Of course to what extent you should approach the coding breadth first vs depth first will depend on how clear of an idea you have for the design. If you were just doing a near-clone of Doom and you have done this before then maybe you can just rabbit hole pretty deep from the get go.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#110
post #61

Earlier quoted context omitted.

In this case, it's just that the decompiler didn't think of "else if" as a single control flow construct/keyword in the way that the original programmers did. What was no doubt written like this: if(a Decompiled into this: if(a

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?
Post reply on HN