tef

bad poster & mediocre photographer

  • they/them

mogwai-poet
@mogwai-poet

which consists of people looking at a screenshot of code that is straightforward and getting angry that it's not more complicated.

I'd just like to posit here that a straightforward solution is an excellent default and you should have a really solid argument for the advantages of a complicated solution before you choose it.


tef
@tef

every time there's a "look at this gamedev code" post, it's usually from a cs graduate, often fresh.

for them, code is a means to demonstrate knowledge

they've never been tested on "making things maintainable" or "exploratory programming", but they have had to spend exam after exam writing code to show that they know fancy tricks. the idea that code can be boring is almost anathema.

this habit continues well into their career: you don't have to look further than a technical interview or code review to see more senior programmers setting up elaborate games to show how clever they are.

that's why when they bump up against gamedev code, be it 5000 if statements, or three state machines lovely crafted into a powerset to handle events, it just feels wrong. the code works, does what it needs to, but no-one gets to feel smart about it. what gives?

"i get it, you've only seen code in a textbook"


tef
@tef

i promised myself i wouldn't talk about "the effectiveness of the code" but i have encounted two earnest replies talking about "just a little bit of cleanup" but both fail to understand that's how the code in question got that way

step one: hey, these business rules (game logic) are clunky to write, let's be more OOP about it

step two: ok it turns out even when you add objects and callbacks, 5000 rules still looks like shit, and being in c++ means it's hard to change our minds

step three: let's put these rules out into a DSL to handle it. let's not write our own DSL. let's use Lua, load it at runtime, and we can change things on the fly. the code's still a mess but it's very contained and the boilerplate is minimal

you are here. this is where you are, and yet some of you have the gall to suggest a step four

"what if we wrote something more oop" in lua that does not have objects or classes. "what if we put it in functions and a hash table" then rules that operate on more than one object become four times as cumbersome.

"what if" what if we didn't just blindly suggest things without taking one second to ask how they got that way.


You must log in to comment.

in reply to @mogwai-poet's post:

in reply to @tef's post:

I'm reminded of this one time I saw someone try to launch a crusade against some game based on the filesize of the game's code minus any assets. The logic was literally "they raised all this money on Kickstarter to make not even a megabyte of code."

I also think (without having every done any game dev) that plasticity of code is uniquely important to game dev. Someone who builds CRUD servers for a large company such as myself is operating under fundamentally different constraints, timelines and goals than an indie game developer does. It shouldn't surprise that "what good code looks like" is different

in reply to @tef's post:

unless i saw a different screenshot i also don't really get why you would try to be clever about it? the if-elseif statement did not look particularly big, hard to read or hard to maintain. i feel like it would be worse if you wrote it any other way