Translators
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 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 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 code | Object code |
|---|---|
| Written by a programmer | Produced by a translator |
| High-level, English-like statements | Binary machine instructions |
| Readable and editable | Not readable or editable |
| Must be translated before it can run | Run 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.
Edexcel GCSE Computer Science · Translators