A computer program goes through many phases from its development to execution. From the human readable format (source code) to binary encoded computer instructions (machine code). Here in this section, I will be explaining the different phases of a program during its entire lifespan.
Source code is a plain text file containing computer instructions written in human readable format. It is simple text file written by programmers. It contain instructions in high-level language that the programmer intended to perform by a program. Source code is later compiled and translated to Object code.
Object code is a sequence of computer instructions in an intermediate language. It is generated by compiler after the compilation process. The compiler reads source code written in high-level language and translates it to an intermediate language. After translation a file containing instructions encoded in some intermediate language is generated called object code.
Note: The intermediate language may or may not be machine language.
Despite of being in binary language object codes cannot execute by its own as they lack the main entry point. Various object codes are further linked together by a linker to generate final executable file.
Machine code is a set of computer instructions written or translated in machine language. It is the final executable file generated by compiling, assembling or linking several object files together. It is the only code executed by the CPU.
Machine code and object code both are encoded in machine language and may seem to be similar in nature. However, you can directly execute a machine code, whereas object codes cannot execute on their own. Machine code is the result of linking several object files together. Whereas object code is a result of translating source code of single module or program into machine language. Machine code always contains an entry point to the program while object code does not contain any entry point.