In this chapter, we will distinguish lower generation languages, 1st and 2nd generation, from higher generation languages, 3rd and 4th generation. We will also make reference to tools used to convert between different generations and machine code; compilers, interpreters and assemblers.
Glossary
Machine Code | Language consisting of binary or hexadecimal instructions. |
Assembly Language | A low-level programming language designed for a specific type of processor. |
Mnemonic | A short-code for a machine instruction e.g., LDA. |
Low-level Language | Programming language that provides little or no abstraction from a computer's instruction set architecture e.g., machine code and assembly. |
High-level Language | Programming language that are abstracted from computer hardware making them portable e.g., C++, Python, Java and SQL. |
Generations of Languages
Like humans, programming languages have evolved over the decades to become more and more complex. In the beginning, instructions were were in machine code, which in reality is equivalent to binary because it is the only language a computer can work with. As time went by programmers dedicated time to making languages more abstract and easier to work with, such that they can be converted to machine code in the background. We will learn more about this process in Chapter 49. This meant that programmers were able to program more complex algorithms with fewer lines of code. Hereunder we introduce our spectrum of languages in the following diagram.
Let's start from the beginning shall we?
Low-level languages: 1GL, 2GL
The first two language generations we will be looking at (1GL and 2GL) are very closely tied to the computer's architecture i.e., which CPU it uses and the size of registers. Both machine code which is 1GL and assembly which is 2GL, require a lot of effort from the programmer to use the right instructions, in the right order, working at the level of the computer's internal hardware, therefore, we say that they are low-level languages.
First Generation (1GL) is Machine Code
The first-generation programming language is a machine-level programming language. It consists of 1's and 0's, the machine code i.e., the only language that the computer understands. It did not require a translator because it could be understood by the computer. In this case, the programmer needed to write instructions directly in the language that the computer understands, which also meant that they needed knowledge of the architecture of the computer.
Notice in the example above how the instructions are written in 1's and 0's, the rest are comments for the programmer to remember what that line actually does.
The Second Generation (2GL) is Assembly
A second-generation programming language is a term that refers to the assembly language. Unlike first-generation programming languages, the code can be read and written more easily by a human because it uses mnemonics, which are short-codes for CPU instructions that are used to help the programmer remember what they do.
However, code in assembly must be converted into a machine-readable form to run on a computer. The conversion process is simply a mapping of the assembly language code into binary machine code and is done by an assembler.
Assembly language is specific to and dependent on a particular processor family and environment so it is also a low-level language. Since it is the native language of a processor it has significant speed advantages, but it requires more programming effort than high-level languages and is difficult to use effectively for large applications.
High-Level Languages: 3GL, 4GL
We will be having a look high-level languages or HLL. This break from low-level languages is because from here on, the language is not tied to the architecture of the computer running it. This makes programs written in these languages much more portable.
Third Generation (3GL): C++, Java and Many More.
A third-generation language, 3GL is a programming language syntax is designed or a human to understand. These represent a lot of mainstream languages, like Visual Basic, C++, Java or .Net and Python. Some of these languages have evolved to be easier to use than others over the years, like how .Net is easier than C++, but all of them allow the programmer to focus on the problem, rather than how to use the specific machine architecture to solve it. This means that a Java program written on one computer can easily be run on a different computer. In fact, most modern languages that are popular today are 3GL.
But computers can only understand machine code so a conversion process is required! The 'conversion' is handled by compilers and interpreters, which take the source code written in the particular language and convert it to machine code for the specific architecture. This aspect is discussed in great detail in Chapter 49.
Fourth Generation (4GL): SQL, Scratch and Many More
A fourth-generation programming language, 4GL is a programming language designed with a specific purpose in mind, such as the development of commercial business software. Such languages are meant to be easier than HLLs. Many 4GLs are database languages e.g., SQL which refers to Structured Query Language.
When would you use each level?
While the use of 1GL and 2GLs has reduced, there are still some cases for use, such as device drivers of specific hardware or really small embedded systems. You would also prefer these lower-level languages in cases where space and memory are limited example think Apollo 11 space capsule!
3GLs are widely used by professional programmers to build websites, mobile apps and business applications. Although, we are seeing 4GLs gain popularity. On the horizon, we are starting to see 5GLs, which focus on Artificial Intelligence languages, where the programmer uses code to instruct a program on how to learn!
Commentaires