News for hackers. Stuff that matters.
Re:Absolute truths I unlearned as junior developer by snazz on Friday June 07, 2019 @10:45AM (#20125042)
This is true with basically everything. Game development attracts more than its fair share of truly horrid code, to the point where success seems almost inversely correlated to code quality. If you decompile Terraria (using CIL, which preserves the object design), for instance, you'll notice that its main class is over 40kLOC and that basically all of the business logic is encoded in one great big chain of if-statements. However, the game has been extremely popular and successful (and is pretty fast, and looks really pretty).

Somewhere there is a balance, but for business purposes it leans closer to the "working ugly hack" side.

Re:Absolute truths I unlearned as junior developer by BurningFrog on Friday June 07, 2019 @11:19AM (#20125425)
Maybe games can get away with more things because when they're done, they're (often) DONE.

There is no next release, maintenance, new features etc. Once Balloon Pirates is done it ships, and is never touched again.

Re:Absolute truths I unlearned as junior developer by technomalogical on Friday June 07, 2019 @11:42AM (#20125690)
I don't think that's been the case for a long, long time. Almost every new game on modern consoles and PCs will see one (or many) updates in its lifetime. Game cartridges, things we used to think of as immutable, are merely storage devices for delivery of the original game code. Two recent games I purchased for the Nintendo Switch, on cartridge, both required a download before I could play them.
Re:Absolute truths I unlearned as junior developer by lotu on Friday June 07, 2019 @11:59AM (#20125890)
It's more blurry but Games are still DONE in a way that an ongoing project where new features are constantly being added aren't. There are some exceptions like Minecraft but on average most games can not economically justify multiple full time engineers working on them for over a decade.

There is also the side issue of game engines which many teams reuse from game to game so maybe that doesn't really apply.

Re:Absolute truths I unlearned as junior developer by PsylentKnight on Friday June 07, 2019 @01:15PM (#20126730)
Terraria has been getting updates for 8 years now. Maybe that's why it's such a mess.
Re:Absolute truths I unlearned as junior developer by bspammer on Friday June 07, 2019 @01:33PM (#20126864)
This is very far outside my realm of expertise but isn't it possible they're running some sort of obfuscation on the binary before releasing? 40k LOC seems unbelievable to me, surely even scrolling around in a text editor would be laggy as hell.
Re:Absolute truths I unlearned as junior developer by gridlockd on Friday June 07, 2019 @10:53AM (#20125136)
> all of the business logic is encoded in one great big chain of if-statements

One of the big lies of OO design is that you can manage that kind of complexity better with objects/classes, that you should factor out functionality into tiny pieces, and so on.

Unless you have written (and debugged!) an actual video game, you should spare your judgement.

Re:Absolute truths I unlearned as junior developer by Faark on Friday June 07, 2019 @02:29PM (#20127362)
There are certainly disadvantages. For a start, it keeps freezing my VS code :D

But Modders also have a hard time adding features if logic for all items is in a single function. This seemed exactly what OOP / interfaces were designed for.

Also I'd love to see Terraria's actual source code. The de-compiled versions hat a ton of stuff like

> if (num1 != 109 && num1 != 110 && (num1 != 113 && num1 != 115) && (num1 != 116 && num1 != 117 && num1 != 118)) return;

or

> else if ((int) Main.tile[i, j].type == 19) Type = 94;

20x in a row, with obviously different numbers. Hope the actual code was more readable and just lost a lot in translation. But many more readable styles should be visible in IL (enums, constants, etc). There might also have been some obfuscation (can't remember), but couldn't have a strong one since names were preserved.

But yes, there are also advantages to their style of code. And in the end they delivered a product and that's all that counts.

Re:Absolute truths I unlearned as junior developer by wa1987 on Friday June 07, 2019 @01:27PM (#20126820)
Exactly, having conditionals being spread throughout the program is a great way to increase complexity.

Rules engines, statecharts and other forms of (declarative) behaviour modelling solve real problems.