Computer coding is the process of writing instructions in a programming language so that a computer can perform tasks. Code works because software translates these human-readable instructions into machine instructions that the computer's processor can execute.
This topic is shared by SL and HL students under IB Digital Society 3.3 Computers, particularly uses and forms of computer coding.
A computer automatically executes sets of instructions. However, its central processing unit (CPU) ultimately operates using machine code represented by binary digits. Writing a complex program directly in binary would be inefficient and highly prone to error, so programmers use languages such as Python, JavaScript, or Java.
The mechanism follows four main steps:
- A programmer identifies a task and designs an algorithm, a finite and unambiguous sequence of steps for solving a problem.
- The programmer expresses that algorithm as source code using the vocabulary, syntax, and rules of a programming language.
- A compiler translates the program before execution, or an interpreter translates and executes it as the program runs.
- The processor executes the resulting machine instructions, producing an output or changing stored data.
For example, the Python instruction print("Hello") tells the computer to display text. The processor does not directly understand the English word print; Python's implementation translates the instruction into lower-level operations that the hardware can execute.
A common misconception is that coding and algorithms are identical. An algorithm is the logical sequence of steps, while code is one representation of those steps in a programming language. Different languages can implement the same algorithm.
In an IB exam, an explain question requires more than defining coding. Show the causal chain from algorithm to source code, translation, machine instructions, and processor execution. Keep the technical detail socially relevant: Digital Society examines how coding creates digital systems and shapes their impacts on people and communities, rather than testing advanced software engineering.