Over the years, computer languages have been evolved from Low-Level to High-Level Languages. In the earliest days of computers, only Binary Language was used to write programs. The computer languages are classified as follows:
reference
Machine Language (low level language)
Low-Level language is the only language which can be understood by the computer. Low-level language is also known as Machine Language. The machine language contains only two symbols 1 & 0. All the instructions of machine language are written in the form of binary numbers 1's & 0's. A computer can directly understand the machine language.Middle-level language is a computer language in which the instructions are created using symbols such as letters, digits and special characters. Assembly language is an example of middle-level language. In assembly language, we use predefined words called mnemonics. Binary code instructions in low-level language are replaced with mnemonics and operands in middle-level language. But the computer cannot understand mnemonics, so we use a translator called Assembler to translate mnemonics into machine language.
Assembler is a translator which takes assembly code as input and produces machine code as output. That means, the computer cannot understand middle-level language, so it needs to be translated into a low-level language to make it understandable by the computer. Assembler is used to translate middle-level language into low-level language.
g++ -S main.cpp -o main.sHigh Level Language
High-level language is a computer language which can be understood by the users. The high-level language is very similar to human languages and has a set of grammar rules that are used to make instructions more easily. Every high-level language has a set of predefined words known as Keywords and a set of rules known as Syntax to create instructions. The high-level language is easier to understand for the users but the computer can not understand it. High-level language needs to be converted into the low-level language to make it understandable by the computer. We use Compiler or interpreter to convert high-level language to low-level language.
Languages like FORTRAN,C, C++, JAVA, Python, etc., are examples of high-level languages. All these programming languages use human-understandable language like English to write program instructions. These instructions are converted to low-level language by the compiler or interperter so that it can be understood by the computer.
g++ main.cpp
show understanding of the need for both high-level and low-level languages • show understanding of the need for compilers when translating programs written in a high-level language • show understanding of the use of interpreters with high-level language programs • show understanding of the need for assemblers when translating programs written in assembly language This is because computers are electronic devices that can only tell the difference between the on and off states of an electric circuit. The numbers 1 and 0 are used by humans to represent these on/off values. That’s why things written in binary look like this: 01010010010001010101011001001001010100110100010100100001 Machine code:
Programming languages can be classified into low-level and high-level languages Low-level languages Assembly: To make it easier to program computers a programming language was invented. It was called ‘Assembly‘ and was made up of a small set of command words called mnemonics which programmers typed instead of binary Examples of mnemonics are “MOV”, “ADD” and “PUSH” Computers could not understand Assembly so it had to be converted to machine code by an ‘assembler‘before it could be run
High-level languages High level programming languages are more developed than low-level languages so are closer to human spoken language
Converting to Machine Code Translators:
There are two different types of translator: Compilers and Interpreters Compilers:
Interpreters:
Show understanding of the need for both high-level and low-level languages Computers don’t understand high level languages because they only understand binary (‘machine code’). Humans struggle to understand exactly what a program does when it is in binary only. High-level languages are more accessible to programmers. High-level languages will work on different types of computers. Low-level programming allows for hardware to be controlled directly. Low-level programming will only work with the processor it is designed for (machine-dependent). understand the need for compilers when translating programs written in a high-level language Translates the entire program from source (i.e. high-level language) to object code / machine code. Produces an executable file (i.e. In binary / machine code) Source code remains hidden so cannot be modified by customer Compiled once only so doesn’t need a translator Compilers use a lot of computer resources: It has to be loaded in the computer’s memory at the same time as the source code and there has to be sufficient memory to hold the object code Difficult to pin-point errors its source in the original program. Show understanding of the use of interpreters with high-level language programs Interpreters translate each instruction is taken in turn and translated to machine code. The instruction is then executed before the next instruction is translated. Error messages are output as soon as an error is encountered so easy to debug Useful for prototypes as program will run even when part of it has errors. Execution of a program is slow compared to that of a compiled program. Instructions inside a loop have to be translated each time the loop is entered. Understand the need for assemblers when translating programs written in assembly language Assemblers translate assembly language to machine code / binary / object code. |