Menu

Translators

Source Code and Object Code

Source code and object code are the two forms a program takes either side of translation. Source code is what a programmer writes; object code is what the processor runs.

Source code

Source code is the high-level code written by a programmer. It is built from English-like statements, such as a print() call or an assignment, so a person can read it, follow the logic and change it. It is stored as a text file that can be opened and edited whenever you like.

This short program is source code: every line can be read and understood by a person.

# A short program written in source code
level = 2
bonus = 50
points = 120
total = points + bonus
print("Level " + str(level) + ": " + str(total) + " points")

Output:

Level 2: 170 points

Object code

Object code is the machine code produced from that source code by a translator. It is a pattern of binary instructions, 1s and 0s, that the processor can act on directly. Because it is written for the processor rather than for a person, you cannot make sense of it or edit it by hand. You may also see object code called machine code, an executable or a binary.

Source codeObject code
Written by a programmerProduced by a translator
High-level, English-like statementsBinary machine instructions
Readable and editableNot readable or editable
Must be translated before it can runRun directly by the processor

A compiler produces object code, and that object code can be saved to storage and run later, so a program can be used on a machine that holds neither the source code nor the compiler. An interpreter produces no object code at all, so there is nothing left behind to save. That is the difference the terms are really about: source code is the form a person writes and edits, while object code is the binary form the processor runs.

Source code is translated by a compiler into object code, which is saved to storage and run by the processor; an interpreter produces no object code.

Practise this