Programming Languages
From Algorithm to Code
You can design an algorithm in your head, describe it in a flowchart, or write it as numbered steps. But to make a computer perform it, you must write it in a language the computer can be given β a programming language. The written result is called code (or source code), and writing it is programming.
A programming language is a real language: it has vocabulary and grammar (programmers say syntax). What makes it different from English is a single, strict requirement: no ambiguity. Every statement must mean exactly one thing.
Why Not Just English?
Try this instruction on a literal-minded robot: "Put the milk in the fridge." Which milk? Which shelf? Should it open the door first? Close it after? Humans fill gaps with common sense; computers have none. English drips with ambiguity β jokes, idioms, and misunderstandings all live in those gaps.
So programming languages are deliberately small and strict. In Python, a popular language, this is real code:
if score > highscore:
print("New record!")
Notice there is nothing to interpret. score > highscore is either true or false β pure Boolean logic β and the condition decides exactly what happens. The strictness is the point: it is what lets the machine execute your intent, not its guess at your intent.
The Ladder of Languages
At the very bottom sits machine code β the CPU's native tongue. It is pure binary: numeric instructions like 10110000 01100001 that the processor executes directly. Early programmers really wrote this, by hand. It is exhausting and error-prone.
Every language above it is a rung on a ladder of abstraction:
- Low-level languages (like assembly) name the CPU's instructions but stay close to the metal: one line β one machine instruction. Maximum control, maximum effort.
- High-level languages β Python, Java, JavaScript, C++, and hundreds more β are written for human thinking. One line can do what needs dozens of machine instructions, and the hardware details are hidden.
- Block-based languages β like Scratch β replace typed text with snap-together blocks, so beginners can build real sequences, loops, and conditions without ever hitting a spelling error.
Higher is not "better" β it is a trade-off. High-level code is faster to write, easier to read, and easier to debug; low-level code offers fine control where it is truly needed.
Translators: Compilers and Interpreters
Here is the catch: the CPU only runs machine code. Your Python or Scratch is unreadable to it. Between your code and the processor stands a translator β itself a program β in one of two styles:
- A compiler translates your entire program into machine code ahead of time. The result runs directly and fast. (Big games are compiled.)
- An interpreter translates and executes your code line by line, as it runs. Slower, but wonderfully immediate β change a line, run it again instantly.
Either way, the destination is the same: your idea, expressed in a human-friendly language, ends up as binary instructions marching through the fetchβdecodeβexecute cycle.
Why So Many Languages?
Thousands of programming languages exist because they are tools, each shaped for a job: JavaScript for web pages, Python for data and learning, C++ where speed is everything, Scratch for starting out.
But β and this is the encouraging secret β they are far more alike than different. Virtually every one is built from the same handful of ideas you already know: sequence, selection, repetition, variables, and inputs and outputs. The algorithm is the idea; the language is merely the handwriting. Learn one language properly and the second comes cheap, because you are not relearning the ideas β only new spelling for them.
Worked Example β The Same Algorithm, Three Languages
To see "different spelling, same idea" concretely, here is one small algorithm β output "Pass" if a mark is 40 or above, otherwise "Fail" β written in three different real styles:
Pseudocode (from this course):
IF mark >= 40 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF
Python (a real high-level language):
if mark >= 40:
print("Pass")
else:
print("Fail")
Scratch (a real block-based language):
[if <mark >= 40> then]
[say "Pass"]
[else]
[say "Fail"]
Every version has exactly the same shape: a condition, a THEN branch, an ELSE branch. Python uses indentation and a colon instead of ENDIF; Scratch replaces typed keywords with snap-together blocks entirely. None of these differences touch the logic β they are purely differences in syntax, the surface-level spelling rules of each language. A programmer fluent in one of these can read the others almost immediately, because the underlying idea (an IF/ELSE decision) was already familiar β exactly the "learn once, transfer everywhere" claim this lesson makes.
Key Words
- Programming language β a precise, unambiguous language for writing computer instructions
- Code / source code β a program as written by the programmer
- Machine code β binary instructions the CPU executes directly
- High-level / low-level β closer to human thinking / closer to the hardware
- Compiler β translates a whole program to machine code before it runs
- Interpreter β translates and runs code line by line