An object code must be translated into source code for a computer to read and execute it

1. Source Code: 
Source code refers to high level code or assembly code which is generated by human/programmer. Source code is easy to read and modify. It is written by programmer by using any High Level Language or Intermediate language which is human-readable. Source code contains comments that programmer puts for better understanding. 

Source code is provided to language translator which converts it into machine understandable code which is called machine code or object code. Computer can not understand direct source code, computer understands machine code and executes it. It is considered as fundamental component of computer. In simple we can say source code is a set of instructions/commands and statements which is written by a programmer by using a computer programming language like C, C++, Java, Python, Assembly language etc. So statements written in any programming language is termed as source code. 

2. Object Code: 
Object code refers to low level code which is understandable by machine. Object code is generated from source code after going through compiler or other translator. It is in executable machine code format. Object code contains a sequence of machine understandable instructions to which Central Processing Unit understands and executes. 

Object file contains object code. It is considered as one more of machine code. Some object file examples are common object file format (COFF), COM files and “.exe” files. It is the output of a compiler or other translator. We can understand source code but we can not understand object code as it is not in plain text like source code rather it is in binary formats. 

The below figure illustrates the source code and object code: 

An object code must be translated into source code for a computer to read and execute it

Difference between Source Code and Object Code :

S. No. SOURCE CODE OBJECT CODE
01. Source code is generated by human or programmer. Object code is generated by compiler or other translator.
02. Source code is high level code. Object code is low level code.
03. Source code is written in plain text by using some high level programming language. Object code is translated code of source code. It is in binary format.
04. Source code is human understandable. Object code is not human understandable.
05. Source code is not directly understandable by machine. Object code is machine understandable and executable.
06. It is written in a high-level language like C, C++, Java, Python, etc., or assembly language. It is written in machine language through compiler or assembler or other translator.
07. It can be easily modified. It can not be modified.
08. It contains comments for better understanding by programmer. It does not contain comments for understanding by machine.
09. It contains less number of statements than object code. It contains more number of statements than source code.
10. It is less close. towards machine. It is more close towards machine.
11. Performance of source code is less than object code as it is less close towards machine. Performance of object code is more than source code as it is more close towards machine.
12. Source code is input to compiler or any other translator. Object code is output of compiler or any other translator.
13. Source code is not system specific. Object code is system specific.
14. It can be changed over time. Source code needs to be compiled or translated by any other translator to get modified object code.
15. Language translators like compiler, assembler, interpreter are used to translate source code to object code. Object code is machine code so it does not require any translation.
16. The source lines of code gives the readability and understandability to the user. Use of fewer lines of code gives better performance by giving same results in most cases. This is not the case with object code.

Source code is the fundamental component of a computer program that is created by a programmer. It can be read and easily understood by a human being. When a programmer types a sequence of C programming language statements into Windows Notepad, for example, and saves the sequence as a text file, the text file is said to contain the source code. 

Source code and object code are sometimes referred to as the "before" and "after" versions of a compiled computer program. For script (noncompiled or interpreted) program languages, such as JavaScript, the terms source code and object code do not apply, since there is only one form of the code.

Programmers can use a text editor, a visual programming tool or an integrated development environment (IDE) such as software development kit (SDK) to create source code. In large program development environments, there are often management systems that help programmers separate and keep track of different states and levels of source code files. 

Licensing of source code

Source code can be proprietary or open, and licensing agreements often reflect this distinction.

When a user installs a software suite like Microsoft Office, for example, the source code is proprietary, and Microsoft only gives the customer access to the software's compiled executables and the associated library files that various executable files require to call program functions.

By comparison, when a user installs Apache OpenOffice, its open source software code can be downloaded and modified. 

Typically, proprietary software vendors like Microsoft don't share source code with customers for two reasons: to protect intellectual property and to prevent the customer from making changes to source code in a way that might break the program or make it more vulnerable to attack. Proprietary software licenses often prohibit any attempt to discover or modify the source code.

Open source software (OSS), on the other hand, is purposely designed with the idea that source code should be made available because the collaborative effort of many developers working to enhance the software can, presumably, help make it more robust and secure. Users can freely take open source code under public licenses, such as the GNU General Public License.

Purposes of source code

Beyond providing the foundation for software creation, source code has other important purposes, as well. For example, skilled users who have access to source code can more easily customize software installations, if needed.

Meanwhile, other developers can use source code to create similar programs for other operating platforms -- a task that would be trickier without the coding instructions.

Access to source code also allows programmers to contribute to their community, either through sharing code for learning purposes or by recycling portions of it for other applications.

Organization of source code

Many different programs exist to create source code. Here is an example of the source code for a Hello World program in C language:

/* Hello World program */

#include<stdio.h>

main()
{
printf("Hello World");

}

Even a person with no background in programming can read the C programming source code above and understand that the goal of the program is to print the words "Hello World." In order to carry out the instructions, however, this source code must first be translated into a machine language that the computer's processor can understand; that is the job of a special interpreter program called a compiler -- in this case, a C compiler.

After programmers compile source code, the file that contains the resulting output is referred to as object code.

Object code consists mainly of the numbers one and zero and cannot be easily read or understood by humans. Object code can then be "linked" to create an executable file that runs to perform the specific program functions.

Source code management systems can help programmers better collaborate on source code development; for example, preventing one coder from inadvertently overwriting the work of another.

History of source code

Determining the historical start of source code is a subjective -- and elusive -- exercise. The first software was written in binary code in the 1940s, so depending on one's viewpoint, such programs may be the initial samples of source code.

One of the earliest examples of source code as we recognize it today was written by Tom Kilburn, an early pioneer in computer science. Kilburn created the first successful digital program held electronically in a computer's memory in 1948 (the software solved a mathematical equation).

An object code must be translated into source code for a computer to read and execute it
Tom Kilburn's highest factor routine

In the 1950s and '60s, source code was often provided for free with software by the companies that created the programs. As growing computer companies expanded software's use, source code became more prolific and sought after. Computing magazines prior to the internet age would often print source code in their pages, with readers needing to retype the code character for character for their own use. Later, floppy disks decreased the price for electronically sharing source code, and then the internet further deleted these obstacles.

This was last updated in September 2019

Continue Reading About source code

  • The value of running security analysis tools against source code
  • Learn how various computer languages work
  • How to properly use open source libraries
  • How a source code strategy can help with automating version control

Dig Deeper on Application development and design

  • An object code must be translated into source code for a computer to read and execute it
    compiler

    An object code must be translated into source code for a computer to read and execute it

    By: Robert Sheldon

  • An object code must be translated into source code for a computer to read and execute it
    build

    An object code must be translated into source code for a computer to read and execute it

    By: Katie Terrell Hanna

  • An object code must be translated into source code for a computer to read and execute it
    runtime

    An object code must be translated into source code for a computer to read and execute it

    By: Ben Lutkevich

  • An object code must be translated into source code for a computer to read and execute it
    3 simple Java Hello World examples

    An object code must be translated into source code for a computer to read and execute it

    By: Cameron McKenzie

What is used for random access processing of data in a computer?

Primary storage Random access memory – called RAM, this is where data and programs are transferred to (from secondary storage) when the CPU requires them. It is volatile in that the contents of RAM are only available when the computer is on.

What is a type of server that stores computer software which users can access from their workstations?

File servers only make a remote file system accessible to clients. They can store any type of data -- for example, executables, documents, photos or videos. They generally store the data as blobs of binary data or files.

Is a server set of programs for controlling and managing computer hardware and software?

Operating System (OS) - a set of programs that manage computer hardware resources and provide common services for application software. The operating system acts as an interface between the hardware and the programs requesting I/O. It is the most fundamental of all system software programs.

What is a communication interface through which information is transferred one bit at a time?

In computing, a serial port is a serial communication interface through which information transfers in or out sequentially one bit at a time. This is in contrast to a parallel port, which communicates multiple bits simultaneously in parallel.