this post was submitted on 08 Apr 2025
267 points (99.6% liked)
Games
21348 readers
135 users here now
Tabletop, DnD, board games, and minecraft. Also Animal Crossing.
Rules
- No racism, sexism, ableism, homophobia, or transphobia. Don't care if it's ironic don't post comments or content like that here.
- Mark spoilers
- No bad mouthing sonic games here

- No gamers allowed

- No squabbling or petty arguments here. Remember to disengage and respect others choice to do so when an argument gets too much
- Anti-Edelgard von Hresvelg trolling will result in an immediate ban from c/games and submitted to the site administrators for review.

- Can't read Colon Syntax Emoji? :skill-issue:
founded 6 years ago
MODERATORS
You can go back but it's very difficult. Only the biggest nerds can do it, with great dedication and time. That process is called reverse engineering.
For a very simple example, suppose I wrote some code to add how many apples Jack and Jill have together. The source code might look like
jackApples = 3
jillApples = 4
numApples = jackApples + jillApples
But the computer doesn't care about Jack, or Jill, or apples for that matter. It only cares about numbers. So when the compiler puts it into ones and zeros all those useful names get dropped. And when I decompile the binary (what we call those ones and zeros) what I get back might look more like
var1 = 3
var2 = 4
var3 = var1 + var2
And if I want to change how many apples Jill has it's a whole process of trial and error to figure out which variable is Jill's number of apples.
Now expand that to thousands or millions of lines of code and you begin to see why nerds want source code instead of binaries.
The compiler will see that
var3is just two numbers added together and replace it with 7, which saves having to do an addition every time you run through that code, and is therefore faster.var1andvar2may be removed from the output as well; shorter code runs faster since you can fit more in the cache. In fact, sincevar3is just a number, you can replace every place that it's used with a 7 as well; if you have some functions:... then the compiler will look at all that, delete the lot, and just use
1.4fwherever theappleWeight()function was called. Comment is gone, the decision making is gone, it's impossible to go backwards any more.I'm not a professional programmer and just a hobbyist, but if you also had a set function that changes jackApples to an input integer, what happens at compilation?
That disables a whole pile of the potential optimisations, of course. You could define
jackApplesas a "static variable" (as opposed to making it eg. a field in a class or struct):The most obvious consequence of this is that
jackApplesnow has an address in memory, which you could find out with&jackApples. Executable programs are arranged into a sequence of blocks when they're compiled, which have some historical names based on what they used to be for:textsection, which contains all of the executable code, and which might be made read-only by the OS.datasection, which contains variables that have a known value at startupbsssection, which contains variables that we know will exist but don't have a value. Might be zero'd out by the OS, might contain unknown leftover values.Because it's statically allocated,
jackAppleswill be in thedatasection; if you opened up the executable with a hex editor, you'd see a 3 there.getTheNumberOfApples()will be optimised by the compiler to return the contents of the memory address plus 4. That still counts as a very simple and short function, and it's quite likely that the compiler would inline it and remove the initial function. The actual process of calling a function is to:That takes a while, and worse - modern CPUs will try to "pipeline" all the instructions that they know are coming so that it all runs faster. Jumping to a function might break that pipeline, causing a "stall", which slows things down enormously. Much better to inline short functions - the fact that the value is "number in memory address plus four" might be optimised away a little wherever it's used, too.