A programming language is the way a person tells a computer what to do. The processor understands only machine language, so every other language needs a translator. Learn the three levels of language, then the three translators, then the errors that appear on the way.
Levels of language
Level
Written as
Tied to a processor?
Translator
Machine language
Binary 0s and 1s
Yes
None needed
Assembly language
Mnemonics such as ADD, MOV
Yes
Assembler
High-level language
English-like statements (C, Java, Python, COBOL)
No (portable)
Compiler or interpreter
Machine and assembly languages are low-level: fastest and give full control, but hard to write.
High-level languages are easy to write, read and correct, and the same program works on different computers after it is translated again.
One assembly statement becomes one machine instruction. One high-level statement becomes many.
HTML is a markup language, not a programming language: it describes a page and has no calculations or decisions.
Levels of programming language: high-level, assembly and machine language with an example, the translator needed and how close each is to people or hardware
Translators
Translator
Works on
How it works
Output
Assembler
Assembly language
Converts mnemonics to machine code
Machine code
Compiler
High-level language
Translates the whole program, then lists all errors
Object code (a separate file)
Interpreter
High-level language
Translates and runs one line at a time, stops at the first error
No object file
Source code (written by the programmer) goes through the compiler to become object code. The linker joins object modules and library code into an executable (.exe). The loader puts the executable in memory, and the processor runs it.
A compiled program runs faster later, because it is translated once. An interpreted program is translated again at every run, but it is quick to test.
If one line of a compiled program changes, the program must be compiled and linked again.
Java is compiled to bytecode, which the Java Virtual Machine runs on each type of computer.
Trick: Assembly needs an Assembler, C needs a Compiler, Python needs an Interpreter.
Generations in brief
1GL machine language, 2GL assembly language, 3GL high-level languages (C, COBOL, FORTRAN), 4GL very high-level languages that say what is wanted (SQL), 5GL artificial-intelligence languages (Prolog). Each generation is easier for people and farther from the machine.
What is an algorithm?
An algorithm is a finite, step-by-step set of instructions for solving a problem or doing a task. It is planned before coding, and a flowchart is one way to draw it.
What is a flowchart?
A flowchart is a diagram that shows the steps of an algorithm or process using standard symbols joined by arrows: an oval for start and end, a rectangle for a process, a diamond for a decision and a parallelogram for input or output.
Building blocks of a program
Keyword: a reserved word with a fixed meaning (if, while). Operator: a symbol such as +, -, *, /.
Variable: a named place whose value can change. Constant: a value that never changes.
Decision (if-else): chooses between paths. Loop: repeats statements. Function: a named group of statements used again and again.
Comment: a note for the reader that the computer ignores.
Procedural languages (C) are built from procedures. Object-oriented languages (Java, C++) are built from classes, a class being a blueprint for objects.
Web languages: HTML gives structure, CSS gives style and layout, JavaScript gives behaviour. SQL is a query language for databases. Scripting languages such as JavaScript and PHP are usually interpreted.
Errors and debugging
Error
When it shows
Example
Syntax error
Before the run, during translation
Missing bracket, misspelt keyword
Runtime error
While the program runs
Division by zero
Logical error
Never reported; the output is wrong
`a + b + c / 3` instead of `(a + b + c) / 3`
Debugging is finding and removing errors. A debugger runs a program step by step. An IDE gathers an editor, a translator and a debugger in one program.
Logical errors are the hardest to find: test with sample data whose answers you know, including values at and just outside the limits.
Plan with an algorithm (step-by-step instructions) before coding.
Quick sort test
1. Is it a pattern of 0s and 1s? Machine language. 2. Does it use short codes like ADD and MOV? Assembly. 3. English-like words? High-level. 4. Whole program first, then all errors? Compiler. One line at a time? Interpreter. 5. Program runs but gives wrong totals? Logical error.
Quick Memory Notes
Languages and Translators Set 01
25 questions
Languages and Translators Set 02
25 questions
Languages and Translators Set 03
25 questions
Languages and Translators Set 04
25 questions
Languages and Translators Set 05
25 questions
Sample questions from this set
A preview with answers and explanations. Start the full set above for all questions, instant scoring and negative marking.
1.The language made only of 0s and 1s that the computer understands directly is ______.
A.assembly language
B.machine language✓
C.a high-level language
D.a markup language
Explanation: Concept: Machine language is the only language the processor can run without any translation.
Why: Every instruction is a pattern of binary digits.
Answer: machine language → option B
Trap: Assembly language is close to the hardware, but it still has to be translated first.
2.Instructions in an assembly language are written using short codes called ______.
A.pixels
B.packets
C.mnemonics✓
D.protocols
Explanation: Concept: A mnemonic is a short word such as ADD, SUB or MOV that stands for a machine instruction.
Why: They are easier to remember than strings of 0s and 1s.
Answer: mnemonics → option C
Trap: Packets and protocols belong to networks, and pixels belong to screens.
3.Which of the following is a high-level language?
A.Opcode
B.Binary code
C.Assembly language
D.Python✓
Explanation: Concept: High-level languages use English-like words and are easy to read and write.
Why: Python, C, Java and COBOL are high-level languages.
Answer: Python → option D
Trap: Binary code and assembly language are low-level; an opcode is only a part of a machine instruction.
Program journey: source code is translated by the compiler into object code, the linker builds the executable file and the loader places it in memory to run
1 / 2
Hand-written sticky notes for languages and translators: levels, translators, the journey from source to running program, generations and a matching trick