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.
Latest Answers