Levels of programming languages – from digital computers to virtual machines

Today we have a large number of programming languages available, some with a very specific scope of operability such as the web, analysis and mathematical calculation, or data management. These languages, so high-level and easily interpretable by professionals in the specific sector, are the result of years of evolution, which have managed to transform a binary language, which can only be interpreted by machines (machine code), passing through levels of programming languages gradually more complex. In this article we will see the reasons and ways of this development.

Levels of programming languages - from digital computers to virtual machines

Computer – a digital calculator

The digital calculator, also known as a calculator or electronic processor, is a device based on electronic components capable of performing logical-mathematical calculations in response to the instructions given to it. Today digital calculators are better known as computers, the English term for “calculator”.

Digital computers are therefore composed of innumerable and microscopic electronic circuits that are designed and built to recognize and execute a limited set of simple instructions, such as the addition or shift between bits.

Calcolatore elettronico - computer

Over the past 50 years of computer development, these simple instructions have been used as building blocks to develop increasingly complex instructions, creating a series of basic programming languages. These new instructions, although more complex, have in turn been used as the basis for the realization of new instructions and commands, thus generating programming languages that are gradually higher, but at the same time also more humanly readable.

Programming languages allow us to write programs, which are nothing more than a sequence of instructions or commands. The set of these instructions defines the programming language. And these instructions will somehow have to be converted, or translated, into simpler instructions belonging to a lower level. Therefore, programming languages have gradually developed on top of each other, creating a layered scheme, called layers.

The basic instructions: machine language

When a computer is designed, there is a tendency as much as possible to simplify the basic instructions on which its operation will be based, the set of these instructions defines the machine language (machine code), which is the lowest level of programming language, since it is the one which has direct control over the functioning of the electronic circuits inside.

Linguaggio macchina
Machine code

Machine language is therefore based on a limited set of instructions, the simplest and most direct possible. This allows us to reduce the complexity and cost of the electronic circuits to be made.

Furthermore, it must be added that the machine language is specific to each individual computer. In fact the instructions have been created specifically in the image of the electronics inside the computer and are so highly efficient precisely because they are machine-specific.

I codici macchina sono specifici per ogni calcolatore
Specificity between machine code and computer

Each computer therefore has its own machine language, which may differ from the others and depends exclusively on its internal structure. So it can be said that each machine defines a language. But the inverse is also true, that is, each language defines a machine.

These machine languages, therefore made up of sequences of numbers and alphanumeric codes, are easily readable and interpretable by machines, but they are not at all so for human beings. Hence the need to create a new set of instructions that is as close as ever to concepts familiar to human beings. This creates a new level of programming.

Levels of programming languages

We call the machine code level L1, and this new programming level L2. We have seen that the machine code is composed of a sequence of limited instructions that correspond to simple operations that can be carried out by the electronic circuits inside the computer.

Digital calculators and programming levels 01

So when developing a program at L2 level, it will then need to be converted into machine language at L1 level, since it is the only language that a computer can execute. There are two ways to do this.

  • Translation method. Each instruction of L2 is replaced in the equivalent sequence of instructions of L1.
  • Method of interpretation. You write a program in L1 language, called interpreter, which is able to receive input programs written in L2 and execute them by examining one instruction after another and executing the equivalent sequence of instructions in L1 for each.

This mechanism between L1 and L2 can be generalized to any level with the one below. For example, L4 will be translated into L3 and so on, up to the machine code which is the only one truly executable by the computer.

In analyzing the programming codes from a lower to a higher level, however, we will see some differences. The programming language used becomes more complex, structured and with larger textual parts, more and more similar to human language. In fact, they gradually become more and more readable and manageable by a human user. The higher the level, the more its logic deviates from the basic machine language.

The concept of Virtual Machine

A little parenthesis in the development of this topic. We have said that all the programming levels must be translated gradually down to the machine language, which is the only one that can be interpreted by the computer, that is, by the real machine.

But with the passage of time, the development of many computer architectures, and as many levels of programming, has made this scheme very complex in practice. The programmer of a particular language often does not know neither the mechanisms nor the functioning of the underlying levels. In fact, many professional realities were born, highly specific in the field of programming, which each of them generally develops only on a programming level.

Virtual machine and programming language levels

Quindi, ritornando allo schema generale, possiamo pensare a ciascun livello di programmazione come specifico e operante per una determinata macchina virtuale. Un caso pratico lo abbiamo per la programmazione Java e la corrispondente Virtual Machine. Il programmatore Java sa che il suo codice si adatterà alla Virtual Machine Java che funziona su tutte le architetture possibili in cui è installata, senza doversi mai preoccupare (o quasi) a livello di codice su che architettura stia lavorando.

La macchina virtuale dovrà essere strutturata in modo da garantire l’esecuzione del programma, indipendentemente dal tipo di architettura, numero di livelli, e linguaggi di programmazione sottostanti.

Virtual machine and different hardware
The programming language sees all the different computers as one virtual machine

With the introduction of this concept it is easy to understand that the higher the programming language, the greater the number of types of architectures possible to use with that language. Therefore, the portability of programs developed with that language will also increase. This is completely transparent to the programmer of that language.

Scheme of programming levels in today’s computers

While machine languages, as well as assembly, consist of a series of instructions that include operations on memory bits, elementary and focused on operational detail, the passage to higher levels of language, i.e. system languages, their constructs of logical structures (things useful to human users) that can be worked on.

Programming Languages Levels

System languages focus on representing memory and making algorithms as efficient as possible. Logical and data structures are then introduced on which it is possible to create algorithms and memory constructs to work on. At this level, therefore, we have the first and true step to make a programming language humanly readable.

Going to an even higher level, we have application languages. It is in these levels that the memory constructs become real data models, object-oriented programming is also born, with a whole series of methods and attributes to be assigned to these constructs. There is a great gain in programming speed, with a natural ease of converting real-world problems into written code. All this, however, at the expense of a loss of flexibility and visibility on how low-level memory is managed. It is therefore important at this level that the translation of these instructions into the levels below is carried out as efficiently as possible.

Programming languages and levels

Finally, at the highest levels, we find the 5GL (5th generation language) and DSL (domain specific language) languages. These languages have completely reached the level of human logic, and have reached a level of readability that is sometimes readable even to those who are not very experienced in programming, but expert in the specific subject in which the specific language has been programmed. In fact, languages at this level are created for certain purposes and are often limited to that. There are languages born to manage databases such as different versions of SQL, or to create scientific scripts (MATLAB), or scripts for applications in other professional fields (iCAD) and they cover only these specific areas. At this high level of language, the underlying algorithms, the management of memory structures, and the efficiency of a code are no longer visible, but are left to be managed by the lower levels.

Leave a Reply