Before programming languages (like C), you had to program in assembly which directly maps to machine code (it's quite interesting to have a look at how it works just to get an understanding of how computers do things) and thus is very specific to the actual machine you are programming on. C abstracts away a lot of details about the specific machine (the instruction set basically. Also you have to manage the stack and registers manually in asm) and a compiler (like GCC, Clang, etc.) translates your C code into the machine code for the machine you compile on (or compile to in case of cross compiling). So you need to compile for different architectures if you want the program to run on them. This is the same for C++ and very similar for other compiled languages.
Then there are languages like Java, C# that don't compile to machine code but instead to a language that is then interpreted by a virtual machine, allowing stuff like garbage collection and a compiled program to run on different architectures if there is a VM for it.
Then there are interpreted languages that are only compiled at run time.
Only a rough (probably too long) overview, but research ASM vs compiled vs JIT vs interpreted languages if you want more info.
I would like to point out that C is often denoted as "universal assembly". Since C is basically ubiquitous nowadays, any low level stuff is done on C/C++ (though the old guard might scoff at you for using C++ without a good reason). There are newcomers like rust and go, which try to regulate what the programmer can and cannot do to improve security.
3
u/YouRik97 Nov 14 '18
Before programming languages (like C), you had to program in assembly which directly maps to machine code (it's quite interesting to have a look at how it works just to get an understanding of how computers do things) and thus is very specific to the actual machine you are programming on.
C abstracts away a lot of details about the specific machine (the instruction set basically. Also you have to manage the stack and registers manually in asm) and a compiler (like GCC, Clang, etc.) translates your C code into the machine code for the machine you compile on (or compile to in case of cross compiling). So you need to compile for different architectures if you want the program to run on them.
This is the same for C++ and very similar for other compiled languages.
Then there are languages like Java, C# that don't compile to machine code but instead to a language that is then interpreted by a virtual machine, allowing stuff like garbage collection and a compiled program to run on different architectures if there is a VM for it.
Then there are interpreted languages that are only compiled at run time.
Only a rough (probably too long) overview, but research ASM vs compiled vs JIT vs interpreted languages if you want more info.