Live data from Hacker News

TerrariaClone – An incomprehensible hellscape of spaghetti code

github.com

201–210 of 289 posts

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#201

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

You used to be able to decompile Terraria into perfectly readable code, since its c# and they didnt use an obfuscator. The code base was atrocious, but it is impressive that they got something working, and pretty fun, together as quickly as they did.

These days there are a fair amount of production Unity games out that you can extract full sources for.. Can make for a fun read sometimes.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#202
post #163

Earlier quoted context omitted.

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.

It always was rather onnerous.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#203
post #187

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…

Earlier today I wrote a ruby script to go through a JavaScript file, find all ocurrences where a method was written in a certain way, and convert it to a new format. I realized before writing it that there I would never use this script after today, no one ever had to see it, and it would never get version controlled. So i just wrote it in the quickest "get it functional for 95% of cases and throw an error otherwise"…

That's basically why I have a personal project. Low level C code, no operating system, no heap memory handling on embedded, no problem ! Also, almost no abstractions but "infinite" time spend on pointless micro optimizations tweaking assembly. That's a relief from daily work where I'm much more disciplined.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#204
post #163

Earlier quoted context omitted.

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.

In that case, I think you might have been happier in a language other than Java. :-)

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#205

Earlier quoted context omitted.

"first you learn the value of abstraction, then you learn the cost of abstraction, then you're ready to engineer" https://mobile.twitter.com/KentBeck/status/25831623306839654...

"Any problem in computer science can be solved with another layer of indirection"

Except for the problem of too many layers of indirection.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#206

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…

> no code was too verbose or horrible to stop me from progressing towards my goal

Sounds like programming in go :)

PS. It's a joke, I enjoy go myself.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#207

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 gave me palpitations and then killed my browser.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#208
post #73

Reminds me of a rather insightful comment from a Hackernews a few years ago [1]: > People write MLOC monstrosities in Java because they can. You get some boring financial topic and some sub-par programmers and they'll write as much garbage as the language can possibly sustain. > These things are a testament to how safe and simple Java is as a language. > Not having massive crappy code bases is a negative sign in term…

I think that has a lot to do with the IDE as well. When I'm using Visual Studio, I autocomplete and peek until I find something that even remotely does what I need in the library and move on. I come back and optimize when I see smoke coming out of the CPU or my project manager :) (Of course I'm responsible with my code and this is an exaggeration but could this be called "too mature optimization"? :) )

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#209
post #170

Earlier quoted context omitted.

> allows programmers, these very territorial beasts, to have their own little realms they control My 25 years of programming experience says otherwise. The only place where this works is with good(ish) programmers who are assholes and must have their huge, fragile egos stroked or they'll throw a diva fit. I don't hire or work with those people anymore. Neither should you. Joint code ownership produces better code bec…

I agree that my wording maybe gave a wrong idea about the strength of the "ownership". Code has to be readable and commented and peeking into each other code is welcomed, calling for help or reinforcement on a module is recommended. "Realms" is something that is unenforced and that emerges implicitly. On the other hand, joint code ownership leads to endless discussions about proper whitespace formating, variables nam…

> On the other hand, joint code ownership leads to endless discussions about proper whitespace formating, variables naming and accessors. It leads to never-enforced style rules that no one likes nor follows.

Seems less a problem with joint ownership and more a problem with poor leadership.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#210
post #205

Earlier quoted context omitted.

"Any problem in computer science can be solved with another layer of indirection"

Except for the problem of too many layers of indirection.

And for the problem of insufficient performance.
Post reply on HN