Computer Science › Section G · Programming languages › Topic G.1
Historical perspective: generations and paradigms
Every program you run was once written by a person, but almost nobody writes in the processor's own number codes any more. This topic traces how programming languages climbed away from the machine and why they split into several different styles of thinking.
Why not just write numbers?
A processor executes only machine language: instructions encoded as patterns of bits, as described in the topic "Machine language". Writing a program directly in those codes is slow, and a single wrong digit can send the machine off doing something unintended. Finding and fixing such errors is called debugging. The whole history of programming languages is a series of attempts to let people express algorithms in terms closer to the problem, while still producing something a machine can run.
First and second generations
Machine language is counted as the first generation. From the late 1940s, programmers began writing instructions as short mnemonics, such as ADD, LOAD or JUMP, and giving memory cells descriptive names instead of numeric addresses. A program called an assembler converts these mnemonics back into machine code. Assembly languages form the second generation. They are far easier to read, but each mnemonic still stands for one machine instruction, so the programmer must think in the machine's tiny steps, and the program is machine dependent: moving it to a processor with a different instruction set means rewriting it.
The third generation: machine independence
Third-generation languages raised the level of the primitives. One statement, such as an assignment that adds two values and stores the result, could stand for several machine instructions, and the statement made no reference to registers or a particular processor. A translator called a compiler turns such programs into machine language. FORTRAN, developed by John Backus's team at IBM and released in 1957, targeted scientific calculation. LISP, created by John McCarthy in 1958, was built around list processing and introduced ideas that later shaped functional programming. COBOL, designed by a committee in 1959 and strongly influenced by Grace Hopper's earlier work, aimed at business data processing.
Compilers, interpreters and early pioneers
Two ways of implementing a third-generation language appeared early. A compiler translates the whole program and saves the machine-language version to run later. An interpreter translates and carries out each statement as it goes, keeping no translated copy. Grace Hopper is widely credited with one of the first compilers, the A-0 system of the early 1950s, and with arguing, against resistance from managers, that programs could be written in words rather than codes. The topic "Language implementation: translation and compilers" in this section looks at both approaches in detail.
How independent is machine independent?
In principle, a third-generation program runs on any machine that has a compiler for its language. In practice, compilers sometimes reflected their hardware, producing slightly different dialects of the same language, and vendors added extensions beyond the official language. Standards bodies such as ANSI and ISO publish formal definitions of popular languages to limit this drift. Programs also depend on the operating system for files, windows and networking, so software that runs unchanged across different hardware and different operating systems is described as cross-platform, a stronger goal than machine independence alone.
Beyond the third generation
Later languages added ever more powerful abstractions: a few lines can now call on large libraries, databases and network services. People sometimes speak of fourth-generation languages, meaning problem-oriented tools such as query and report languages, and of a fifth generation built on logic, but these labels are used loosely. A single numbered scale measures how far a language frees the programmer from the machine's details. It cannot capture the different directions languages actually took, which is why computer scientists also classify languages by paradigm.
Four paradigms
A programming paradigm is a fundamental approach to building a solution. The imperative, or procedural, paradigm expresses an algorithm as a sequence of commands that change stored data; FORTRAN, C and Python's everyday style are examples. The declarative paradigm describes the problem and lets a built-in general method find the answer; Prolog and SQL are the usual examples. The functional paradigm builds programs by combining functions that take inputs and produce outputs, as in LISP, Scheme and Haskell. The object-oriented paradigm organises software as objects that hold data and the methods that act on it, as in Smalltalk, C++ and Java.
Paradigms overlap
Paradigms are approaches, not walls. The methods inside an object are small imperative routines, so object-oriented languages keep an imperative core: C++ was built by adding classes to C, and Java and C# borrowed much of C++'s syntax. Python supports imperative, object-oriented and functional styles in one language. Another key fact is that almost every general-purpose language can express any algorithm that any other can. The choice of language affects clarity, safety and speed of development, not whether a solution exists. In practice the job decides: JavaScript is built into every web browser, C and C++ suit operating systems and embedded devices, Java and C# run many large business systems, Python is popular for teaching, scripting and data science, and Rust offers C-like speed with stronger memory-safety guarantees.
Worked example: one task, three paradigms
Task: add up the squares of the even numbers in 3, 4, 5, 6. Steps: (1) Imperative Python: set total = 0, then loop with for n in [3, 4, 5, 6]: and, indented inside the loop, if n % 2 == 0: total = total + n * n. The commands change total step by step. (2) Functional Python: sum(map(lambda n: n * n, filter(lambda n: n % 2 == 0, [3, 4, 5, 6]))). Functions are combined, and no variable is updated. (3) Declarative SQL, for a table nums with a column n: SELECT SUM(n * n) FROM nums WHERE n % 2 = 0; which states the wanted result and leaves the method to the database. (4) Check: the even numbers are 4 and 6, and 16 + 36 = 52. All three give 52.
Worked example: placing a language
Classify a language described as follows: its statements name no registers, one statement can become many machine instructions, and programs are sets of facts and rules that the system searches to answer questions. Steps: (1) No registers and one-to-many translation rule out the first and second generations, so it is at least third-generation in level. (2) The programmer states facts and rules rather than an algorithm, which is the declarative paradigm. (3) A language of facts and rules searched for answers is a logic language, and Prolog, created by Alain Colmerauer's group in Marseille in the early 1970s, is the classic example. The topic "Declarative programming" explains how such searching works.
Common mistakes to avoid
Do not treat the generations as a strict timeline in which each language replaced the last: COBOL and FORTRAN are still in use, and assembly is still written for small devices. Do not confuse an assembler, which converts mnemonics one-for-one into machine code, with a compiler, which expands each high-level statement into several instructions. "Machine independent" does not mean "runs everywhere unchanged"; dialects, extensions and operating-system differences still matter. Finally, a language is not locked into one paradigm, and a newer paradigm is not automatically a more powerful one.
Key takeaways
Machine language is the first generation, assembly the second, and machine-independent high-level languages such as FORTRAN, LISP and COBOL the third. Assemblers translate mnemonics; compilers and interpreters implement high-level languages. Standards and cross-platform design attack the remaining portability problems. Beyond the third generation, the numbered scale blurs, so languages are better grouped by paradigm: imperative, declarative, functional and object-oriented. Paradigms overlap, and nearly all general-purpose languages can express the same algorithms.
Flashcards
Flashcard
Instructions encoded as bit patterns that the processor executes directly
Test your understanding
Question 1 of 5
Why is an assembly-language program described as machine dependent?
Question 2 of 5
How does an assembler differ from a compiler?
Question 3 of 5
A program is a set of facts and rules, and the system searches them to answer questions. Which paradigm is this?
Question 4 of 5
A company moves a FORTRAN program to a new computer with a different operating system and must make small changes. Why?
Question 5 of 5
Which claim about programming paradigms is correct?
