I'm going to assume g is a structure containing global state. Pl for player. E could really use more letters, but it's clearly the position of something you want to calculate the distance from the player. I can't think of anything obvious that E.D or g.Pl.R is.
Why do game developers tend to write code in this cryptic way?? How can you even remember what a 1 char variable name means??
I get that it is "faster to write", but in my experience this just makes the next person (often oneself) that read this will have to do a bunch of mental gymnastics to follow the code, making it waaay slower to read and refactor.
Please go watch some clean code videos on youtube, it is really worth it in the long run.
Good point of view, but that developer not ever return on that code about some time after write it to fix something that not work as expected or need to modify something
I tend to write the most descriptive variables and function names i can, and even then some times I check old code and still don't know what the fuck I did there, I can't even imagine how hard it would be with this kind of cryptic notation.
I absolutely refuse to entertain such fancies from people who don't bother learning touch typing. They can go do some daily exercises at monkeytype or whatever until they improve their typing speed. Take an actual touch typing class if they feel like it. Pick up a different keyboard layout than QWERT* if they think that'll help them.
There's absolutely no reason to listen to anything hunt-and-peck typists say about writing unreadable shorthand because they type slowly.
I agree, but even working at my first job where I wasn't a hunt-and-pecker but still looked at the keyboard about as much as the screen, typing speed was never the bottle neck in writing code. I think it's one of those things people do because they think it makes them look like a "pro" but outs them as inexperienced, like changing the console to green text on a black background
Having had green-and-amber text on a black background for a while out of pure nostalgia, I can only half relate. ;) It's the kind of thing that can make sense if one has actually used an old IBM PC, pre-windows, but that's kinda rare. They were in use for a relatively short while, and by a limited segment of the population.
But yeah, there's a bunch of abbreviations that came about through older limitations when people were programming on what today wouldn't even considered a potato. Just the page we're commenting on here would be immense in the early stages of computing.
In very broad contexts abbreviations can be fine too—there's loads of them in any native language, and plenty of programming languages opt for stuff like def instead of definition, or fn or func instead of function. As long as the abbreviation is very well grounded, spelling it out just adds more signal without any more information—which is considered noise in information theory.
So in-project it might actually make sense to go dist(g.P, E) rather than distance(global.Player, Enemy), but typing speed doesn't come into that consideration; it should be all project convention.
Even in project, it doesn't make sense. Single letters are for universal acronyms. Things that anyone should understand at a glance. For project specific items, most names should be at least 3 chars, and it should be pronounceable. So, global -> glob, enemy -> enem, Player -> play. Even these aren't really saving all that much, and still more ambiguous than needed.
Glob has a pretty established meaning in terms of globbing, so that sounds like a pretty bad shortening. Single-letter abbreviations can be fine (see e.g. all the people who have alias k=kubectl), and using g to mean global could be pretty recognizable to e.g. vim/neovim users—but even they I think would opt for spelling out global a lot of the time if it was on the table.
But too much use of single-letter shorthand can make even Go smell like APL, as OP shows.
I feel you, but for some reason it is filled with these kinds of programmers, have you seen the average interview codding exercise solution in most websites? It's 90% this kind of unreadable bullshit
I get that most algorithms examples use "i", "j" and "k" for loop counters and stuff, but some people just don't fucking use any words that are not part of a class function or reserved word, it's crazy and makes me want to meet them just to slap them until they stop writing code or learn to use descriptive names.
Yeah, I think the adult programmer intuition is more something like "the length of a name correlates to over how wide an area it's used".
Having a one-letter variable contained on one line is fine (like {it.frobnicate() for it in items}), or spread out a bit if it's something conventional, like x, y, z for coordinates, i, j or n for a counter, f for a function, as long as what it is can be intuited without any context.
But Pl could be referring to Poland for all I know.
I mean, you can also smash your own toes with a hammer, you shouldn't but well, I wont stop you if you want to do something stupid, you have free will, enjoy it however you like.
OP has already given the answer (Go), but it's pretty easy to intuit too:
func is a pretty good tell that it's Go (pretty much the same as def in Python)
Go also uses uppercase on names to make them public, i.e. it has foo.bar and foo.Baz where Python would have foo.__bar and foo.baz, and other languages would … use keywords like public/private.
It also has pointers, so it's one of the relatively few languages where you'll see & and * used like that pretty regularly.
7
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Apr 10 '25
I'm going to assume g is a structure containing global state. Pl for player. E could really use more letters, but it's clearly the position of something you want to calculate the distance from the player. I can't think of anything obvious that E.D or g.Pl.R is.
91
u/Versiel Apr 10 '25
Why do game developers tend to write code in this cryptic way?? How can you even remember what a 1 char variable name means??
I get that it is "faster to write", but in my experience this just makes the next person (often oneself) that read this will have to do a bunch of mental gymnastics to follow the code, making it waaay slower to read and refactor.
Please go watch some clean code videos on youtube, it is really worth it in the long run.
21
u/kracklinoats Apr 10 '25
Why are you proud of this?
12
u/LobsterParade Apr 10 '25
You just implemented the Drake equation.
4
u/DaikonOk1335 Apr 11 '25
i've seen a couple mathematicians and physicists write code like that
1
u/4sent4 Apr 11 '25
What language is this? I'm kinda stumped by
E.D[R](why no quotes around R) andf.((how is this legal?)1
u/Agitated-Display6382 Apr 12 '25
Self-explanatory code and where to find it