Source Program vs Object Program
Source program and object program are two types of programs found in computer programming. Source program is typically a program with human readable machine instructions written by a programmer. Object program is typically a machine executable program created by compiling a source program.
What is Source Program?
Source program is a code written by a programmer usually using a higher level language, which is easily readable by the humans. Source programs usually contain meaningful variable names and helpful comments to make it more readable. A source program cannot be directly executed on a machine. In order to execute it, the source program is compiled using a compiler (a program, which transforms source programs to executable code). Alternatively, using an interpreter (a program that executes a source program line by line without pre-compilation) a source program may be executed on the fly. Visual Basic is an example of a compiled language, while Java is an example of an interpreted language. Visual Basic source files (.vb files) are compiled to .exe code, while Java source files (.java files) are first compiled (using javac command) to bytecode (an object code contained in .class files) and then interpreted using the java interpreter (using java command). When software applications are distributed, typically they will not include source files. However, if the application is open source, the source is also distributed and the user gets to see and modify the source code as well.
What is Object Program?
Object program is usually a machine executable file, which is the result of compiling a source file using a compiler. Apart from machine instructions, they may include debugging information, symbols, stack information, relocation and profiling information. Since they contain instructions in machine code, they are not easily readable by humans. But sometimes, object programs refer to an intermediate object between source and executable files. Tools known as linkers are used to link a set of objects in to an executable (e.g. C language). As mentioned above .exe files and bytecode files are object files produced when using Visual Basic and Java respectively. .exe files are directly executable on windows platform, while bytecode files need an interpreter for execution. Most software applications are distributed with the object or executable files only. Object or executable files can be converted back to its original source files by decompilation. For example, java .class files (bytecode) can be decompiled using Decompiler tools in to its original .java files.
What is the difference between Source Program and Object Program?
Source program is a program written by a programmer, while an object program is generated by a compiler using one or more source files as input. Source files are written in higher level languages such as Java or C (so they are easily readable by humans), but object programs usually contain lower level languages such as assembly or machine code (so they are not human readable). Source files can be either compiled or interpreted for execution. Decompilers can be used to convert object programs back to its original source file(s). It is important to note that the terms source program and object program are used as relative terms. If you take a program transformation program (like a compiler), what goes in is a source program and what comes out is an object program. Therefore an object program produced by one tool can become a source file for another tool.