You’re not downloading the source code, you’re basically downloading something that is compiled and turned into something you can run. It’s like trying to guess the recipe by buying a cake. You can make educated guesses and there are ways to reverse steps (at least for software) but you’re not getting the ingredients and the steps, you’re getting something resulting from those.
The files are compiled, which means an interpreter program used the source code to generate executable files and machine code. It is possible but very hard to reverse engineer such files to get *a* source code, but that is not necessarily *the* source code. Hence the named open respectively closed *source*. It is the source code that is unavailable, not the executable program code.
The files you download will contain something called machine code. This is code that the computer can be run, but it is not the code that was used to write the program. Programmers will typically write the program in a programming language and then will use something called a compiler to turn that code into something that the machine will run. There are tools that can turn machine code back into human readable code, but there’s usually a lot of helpful information that is missing, so the code can still be hard to understand and in some cases, the compiler will find ways of scrambling the machine code so that it still works, but makes the code look confusing and garbled when turned back into human readable code.
You are partly correct. A person with the right skills could look at the downloaded files to figure out what it does and even make modifications to them. You can not hide anything secret in these files. However the files you download are not the source code but the machine code. This is a very heavily manipulated code which have been optimized to be read and understood by the CPU, not humans. It is very hard for humans to understand this machine code, not impossible but very hard.
When you buy a cake, can you just look at it to determine the recipe?
It’s the same thing.
The source code is text. It looks like a kind of math-english hybrid with lots of curly brackets all over the place.
The developers feed that to a special program, which reads it, and makes a program which behaves like the source code describes.
That program doesn’t contain the source code, but it was built from the source code.
Just like a cake doesn’t contain the recipe, but it is built from the recipe.
Computers only understand “machine code”, which is very hard for humans to read.
Most humans write programs in a programming language which looks “English-like” that is easier for humans to read and write — these files are called “source code”. Then a program is used to translate the source code files into machine code.
Here’s what source code looks like:
#include <cstdio>
void checkDrinkingAge(int age) {
if (age < 21) {
printf(“Sorry, you’re underage and cannot drink.”);
} else {
printf(“Here’s your drink!”);
}
}
Here’s what the machine code looks like for the same source code:
.LC0:
.string “Sorry, you’re underage and cannot drink.”
.LC1:
.string “Here’s your drink!”
checkDrinkingAge(int):
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-4], edi
cmp DWORD PTR [rbp-4], 20
jg .L2
mov edi, OFFSET FLAT:.LC0
mov eax, 0
call printf
jmp .L3
.L2:
mov edi, OFFSET FLAT:.LC1
mov eax, 0
call printf
.L3:
nop
leave
ret
Even if you don’t know how to program, you will probably not have too much trouble understanding the source code, but probably can’t read the machine code at all.
Machine code is what the files on your device look like. You can try to read it, but it will be nearly impossible to understand. That’s why if you want to understand how a program works, you need the source code.
What you’re downloading is the compiled file and not the actual source code. Source code is human readable text you can easily read with a basic text editor. Trying to open a compiled file with a text editor shows scrambled unreadable garbage.
You can possibly get some of the source code with a decompiler for the appropriate language but it isn’t perfect, stuff would be missing, and names are messed up.
You are downloading the compiled executable file not the source.
It is a bit like the difference between getting a cooked meal and a recipe.
If you analyze the meal closely you can sort of tell what went into it and how you could make the same but that takes a lot of work.
If you use a spectrograph you might be able to guess what goes into the Colonel’s secret recipe, but that is not quite the same as getting the list of the ingredients out of the vault.
With computer code the stuff that people actually write is actually the human readable version. A special program called a compiler turns it into the computer readable version.
There are computer programs that can try to do the opposite thing and de-compile a binary executable into human readable code, but this doesn’t really work all that well most of the time.
For one thing all the comments (if there ever were any) get stripped out and all the variable names etc get lost and you end losing most of the context.
The result of a de-compiler is a piece of code that could be compiled into the same binary but it is not the code that was originally used to make it.
Some programs especially scripts are not compiled and just interpreted into computer instructions by an interpreter each time they are run. If you get a script like that you get both the program and the code behind it because it is the same.
Programmers may try to purposefully obfuscate their code and make their code hard to read, but that can be tricky.
Latest Answers