Depending on the task to be performed, computer programs can be written in high-level languages or low-level languages. Most programmers write programs in high-level languages such as Java, Python, Visual Basic and many more.
High-level languages are portable and can be used on different types of computers. They use English and mathematical symbols in its instructions, therefore requiring no knowledge of the computer hardware and enabling the programmer to focus on the problem to be solved. High-level languages have several advantages insofar as they are easier to:
– read and understand
– write in a shorter time
– debug at the development stage
Low-level languages relate to the specific hardware of a particular type of computer. They can refer to machine code, the binary instructions that a computer understands, or an assembly language that needs to be translated into machine code. Few programmers write code in a low-level language because it is difficult to understand, but those who do, do so for the following reasons:
– to make use of special hardware
– to write code that does not take up much space
– to write code that performs a task quickly.
Low-level languages come in two categories:
– Machine Language – language that is directly understood by the computer (binary notation , 0s and 1s), and it does not need to be translated.
– Assembly Language – the first step to make machine language more readable by humans. An assembly language consists of a set of symbols and letters. It can be called the second generation language because it no longer uses 1s and 0s to write instructions, but terms like MOVE, ADD, SUM and END. Many of the early computer programs were written in assembly languages, but they are still used for Operating Systems and electronic devices, which use very precise timing and operation of computer resources. While easier to understand than machine language, assembly languages are still quite difficult to understand, which is why high-level languages have been developed.
Any high-level language program though, must be translated into binary before a computer can use it. This process is done by a utility program called a translator. There are several types of translator, each one performing a different task:
A compiler is a computer program that translates a program written in a high-level language to the machine level language of a computer. Everything is translated and compiled once by the compiler, and then can be used many times afterwards. One of the advantages therefore, of using a compiler, is that compiled code tends to be faster because it has all been executed in one step prior to its execution, and the source code (the high level language originally used) is hidden.
An interpreter on the other hand, interprets and translates a program written in high-level language to low-level language line by line.
An assembler translates a program written in a low-level language (assembly language) into machine code so that it can be directly used by a computer to perform a required task. Once a program is assembled the machine code can be used again and again to perform the same task without re-assembly.