Explain It Like I'm 5
Programming
What's Programming? How Does It Work?
What's Programming?
Programming is our way of building applications and systems by converting text language into a language the machine can understand
How Does It Work?
Let's assume we're using the C language:
Example
#include <stdio.h>
int main() {
printf("Hello world\n");
return 0; // Process return code -> 0 means no errors
}Linux:
gcc hello.c -o helloLinux:
./helloOutput:
user@computer$ ./hello
Hello world
user@computer$- You run the command
gcc hello.c -o hello- The gcc compiler reads the file (entrypoint)
- First it gets all the referenced headers, in our case:
#include <stdio.h> // stdio.h is the referenced header file- Now it expands any macros you defined with #define (none in our case)
- Removes any comments we've made to our code (like the one I made with the return code)
- Converts the code to Assembly code that match the compiling computer architecture (x86 / ARM)
- Converts that Assembly code into binary (bits and bytes)
- Links calls to external functions mentioned in the header files, in our case:
printf();- Outputs the final file with the name we selected:
hello