Introduction to Programming Languages


Introduction to Programming Languages

Anna
Welcome back to Everything Computerised. Today we’re answering three questions: What is a programming language, why do we need one, and what are the major types and generations of programming languages?

Michael
Let’s begin with the basic idea. When people communicate, they use a language such as English. In the same way, when we communicate with a computer or another digital device, we use a programming language.

Anna
So a programming language is a way for humans to give instructions to machines. Computers cannot work on their own; they need instructions that tell them how to perform a particular task.

Michael
And those instructions have rules, just as spoken and written languages have grammar. In a programming language, the rules are connected with algorithms, which are sequences of instructions or rules used to perform a specific task.

Anna
There are two important parts to understand here: syntax and semantics. Syntax is the structure used to express something—for example, how a command is written, including its punctuation and arrangement.

Michael
Semantics is the meaning of that correctly structured command. In other words, syntax concerns how the instruction is written, while semantics concerns what that instruction means to the computer.

Anna
A useful definition is this: a programming language is a vocabulary and a set of grammatical rules for instructing a computer or computing device to perform a specific task. Each language has its own keywords and special syntax for organizing program instructions.

Michael
Before looking at the generations of languages, we need to know what computers directly understand. Computers are electronic devices, so they work with electrical signals.

Anna
A high electrical signal is represented as 1, and a low electrical signal is represented as 0. These two symbols are called binary digits, or bits. Different combinations of zeroes and ones can represent instructions.

Michael
The programming language made from those binary combinations is called machine language. It is directly understood by the computer, so programs written in machine language do not require a translator.

Anna
Machine language is the first generation of programming languages. It was used from about 1940 to 1959, especially with first-generation vacuum-tube computers and early transistor computers.

Michael
Its main advantage was speed. Because the computer understood the binary instructions directly, machine-language programs could run very quickly without translation.

Anna
But programming in binary was extremely difficult. Even a simple task required a long sequence of zeroes and ones, which made programs lengthy, complex, and difficult for people to understand.

Michael
Machine language was also time-consuming to write and not portable. A program written for one machine generally could not run on another because different machines had different hardware and different machine codes.

Anna
That meant programmers often had to write separate code for each computer. To make programming easier, the second generation was developed: assembly language.

Michael
Assembly language was used around 1959 to 1965. Instead of writing only binary digits, programmers used mnemonics—symbolic representations for machine instructions.

Anna
Those symbols made programs easier to write and understand. They also reduced the chance of errors and saved programming time compared with writing directly in machine language.

Michael
However, a computer could not understand assembly language directly. An assembler was required to translate the assembly source code into machine language, also called object code, before the processor could execute it.

Anna
That translation added time compared with running machine code directly. Assembly language also remained machine-dependent, so code written for one computer generally could not run on another without changes.

Michael
The first and second generations are therefore called low-level languages. They are close to the hardware, but they are difficult to learn, difficult to implement, and not portable.

Anna
The limitations of machine language and assembly language created the need for a more portable and programmer-friendly approach. That led to the third generation of programming languages, developed in 1965 and still used today.

Michael
Third-generation languages are machine-independent, meaning a program written for one computer can generally run on another with no changes or only small modifications. They use English words for variables, commands, and programming structures.

Anna
They also support structured programming. A large program can be divided into smaller sections, with each section performing a particular task. This makes programs easier to write and organize.

Michael
Because of these advantages, third-generation languages are called high-level or programmer-friendly languages. Early examples include FORTRAN, ALGOL, and COBOL. Modern examples mentioned here include C, C++, C-sharp, and Java.

Anna
There is still one important limitation: the computer understands machine language, not high-level source code. So a translator is needed, and translating the code can add time before the program executes.

Michael
The fourth generation moved even closer to ordinary human language. These languages use common English-like syntax and phrases, and they can let one command perform several common operations.

Anna
Fourth-generation languages are designed to be especially programmer-friendly and accessible to people without formal programming training. They work with large collections of information rather than focusing only on individual bits and bytes.

Michael
That made them useful for database management, report generation, mathematical optimization, graphical user-interface development, and web development. Examples include SQL, NATURAL, M-POWER, and LANSA.

Anna
Fourth-generation languages are non-procedural. The programmer states what task should be carried out, while the language determines how to carry it out.

Michael
That makes programming easier, but it reduces the programmer’s control over the program and its resources. Fourth-generation language packages can also be lengthy and may require more disk space and memory.

Anna
The fifth generation was introduced as a concept in Japan in the early 1990s. Its goal is for computers to solve particular problems with minimal help from the programmer.

Michael
With a fifth-generation language, the user focuses on the problem to solve and the conditions that must be met, rather than explaining every routine or algorithm needed to solve it.

Anna
These languages are used mainly in artificial-intelligence research. Examples include OPS5 and MERCURY.

Michael
The trade-off is complexity. Because fifth-generation languages use automated systems, their development and maintenance are more complicated and require more resources to work efficiently.

Anna
Let’s compare the generations directly. The first and second generations—machine language and assembly language—are low-level and machine-dependent. They use binary digits or mnemonic symbols, are difficult to learn, and can interact directly with hardware.

Michael
The third, fourth, and fifth generations are high-level languages. They use English words or phrases, are easier to learn and implement, and are generally machine-independent and portable.

Anna
The important contrast is that high-level programs cannot interact with hardware as directly as low-level programs. They are easier for people to use, while low-level languages provide a closer connection to the machine.

Michael
That brings us to language translators. Since computers understand machine language, translators convert source code written in assembly or a high-level language into machine code, also called object code, so the computer can execute it.

Anna
There are three main types of translators: assemblers, compilers, and interpreters. We’ve already met the assembler—it converts assembly-language code into machine language.

Michael
A compiler translates source code, generally from a high-level language, into machine code as a complete program. It scans and translates the entire program before execution.

Anna
An interpreter also converts source code into machine language, but it works statement by statement. Because translation happens during execution, the overall execution time is increased compared with a compiled program.

Michael
Their error handling is different too. A compiler reports errors after scanning the whole program. An interpreter translates until it reaches the first error, then stops execution at that point.

Anna
In the examples from this lesson, C and C++ use compilers, while Python and Ruby use interpreters. So the complete picture is: programming languages let people communicate instructions to computers, and translators make many of those languages usable by converting them into machine code.

Michael
From binary machine language, to symbolic assembly, to portable high-level languages, and finally to languages designed around human-friendly commands and artificial-intelligence problem solving, each generation addressed limitations of the previous one.

Ask anything
We've read this whole study set, so questions about it get the best answers.