What is a Programming language? | Low-level Vs High-level | SparkEasy

What is a Programming language? Describe Machine language, Assembly language, and High-level language with its merits and demerits.

 

what-is-a-programming-language

 

❃What is a Programming language: A programming language is a computer language used by programmers to communicate easily with computer systems. A programming language is a set of instructions written in any specific language (C, C++, Javascript, Python, Java) mainly used to develop software programs, websites, and desktop/mobile applications.
 
Today, the computer programming language has progressed from machine-oriented language (that use string of binary number 0 and 1) to problem-oriented language. However, all computer programming languages can be understood using machine language.
 
There are mainly three categories of programming languages:-
 
1. Machine language
2. Assembly language
3. High-level language
 

Machine Language

 
Although we can design a computer to make it understand many different computer programming languages, every computer understands only one language (machine language) without using a translation.
 
machine-language

 

In a computer, the machine language includes strings of binary (0s and 1s). The circuitry of a computer system can recognize the instructions in machine language. It converts them into electrical signals which are needed to execute them.
 
We can divide machine language instruction into two parts:-
 
(i) Operation code: It tells the computer what function to perform.
 
(ii) Operand: It tells where to find or store the data on which the computer has to perform the function.
 
Hence, each instruction here tells the computer what operation to perform and the length and locations of the data fields involved.
 
Every computer has a set of operation codes known as an instruction set. Each ‘opcode’ performs a specific operation or function.
 
The operations included in the instruction set of a computer are Arithmetic, Logical, Branch operations (for transfer of control to the address given in the operation field), Data movement operations (for moving data between memory locations and register, and for moving data from input devices to memory, or from memory to output devices).
 
Machine language is not easy to use because it is difficult to read and understand and uses a number system with which we are unfamiliar. However, some of the first programmers who worked with the first few computers wrote their programs in binary form.
 

Merits of Machine language

 
A computer can execute programs written in machine language at great speed because the computer can understand machine instructions without needing translation.
 

Demerits of Machine Language

 
1. Machine dependent: As the internal design of every type of computer is different from every other type of computer, machine language also differs from computer to computer.
 
2. Difficult to write a program: Although a computer executes machine language programs directly and efficiently, it is difficult to program in machine language. It is necessary for a programmer to either memorize the dozens of operation code numbers for the commands in the machine’s instruction set or refer to a reference card constantly.
A programmer must also keep track of storage locations of data and instructions. Moreover, a machine language programmer must be knowledgeable about the hardware structure of the computer.
 
3. Error-prone: A programmer must remember the opcodes and keep track of data storage locations and instructions for writing programs in machine language. It makes it very difficult for them to concentrate fully on the logic of the problem, resulting in programming errors.
 
4. Difficult to modify: It is difficult to correct or alter machine language programs. Checking machine instructions to locate errors is very difficult and time-consuming. Similarly, later changing a machine language program is so tricky that many programmers prefer to code the new logic afresh instead of incorporating necessary modifications in the old program.
 
In short, we rarely use machine language today for writing programs because it is challenging and time-consuming.
 

Assembly Language

 
Assembly language programming, introduced in 1952, helped to overcome the limitations of machine language programming. This language is the most basic programming language available for any processor. It consisted of small instructions called mnemonic codes, used in place of 0s and 1s.
 
assembly-language-program-of-adding-two-numbers
 
With assembly language, a programmer works only with operations implemented directly on the physical CPU. Assembly language is the most powerful computer programming language available, and it gives programmers the insight required to write effective code in high-level languages.
 

Assembler

 
A computer can directly execute only machine language programs, which use numbers for representing instructions and storage location. Hence, we must convert an assembly language program into its equivalent machine language before executing it on the computer. A translator program called Assembler does this translation.
 
Assembler is system software supplied by computer manufacturers. It translates an assembly language program into its equivalent machine language program. It is so called because, in addition to translating, it also “assembles” the machine language program in the computer’s main memory and makes it ready for execution.
 

Merits of Assembly Language over Machine Language

 
1. Easier to understand and use: Due to mnemonics instead of numeric opcodes and symbolic names for data locations instead of numeric addresses, assembly language programs are much easier to understand and use than machine language programs.
 
2. Easier to locate and correct errors: Due to the use of mnemonic opcodes and symbolic names for data locations and also because programmers need not keep track of the storage locations of the data and instructions, fewer errors are made while writing programs in assembly language, and those that are made are easier to find and correct.
 
Additionally, assemblers detect and indicate errors automatically for the use of an invalid mnemonic opcode for an undefined name. For example, let us assume that an assembly language program instruction reads ADD AREA, and we forget to define AREA in the program. The assembler will look through its table; not finding an AREA will indicate the error.
 
3. Easier to modify: Since they are easier to understand, it is easier to locate, correct, and modify instructions of an assembly language program than a machine language program. Moreover, the insertion or removal of particular instructions in a program does not require changing the address of the instructions following that part of the program. It is needed in the case of machine language.
 
4. No worry about addresses: An essential advantage of assembly language is that programmers need not keep track of storage locations of data and instructions while writing an assembly language program.
 
5. Easily relocatable: The availability of pseudo-instructions for instructing the system how we want it to assemble a program inside the computer’s memory makes assembly language programs easily relocatable.
It is because we can easily change a program’s location by changing the pseudo-instructions suitably. It’s not possible easily with machine language programming.
 
6. Efficiency of machine language: An assembly language program also enjoys the efficiency of its corresponding machine language program because there is a one-to-one correspondence between the instructions of an assembly language program and its related machine language program.
In other words, an assembly language program will be just as long as the resulting machine language program. Hence, leaving out the translation time required by the assembler, the actual execution time for an assembly language program and its equivalent machine language program (written independently) would be the same.
 

Demerits of Assembly Language

 
1. Machine dependent: Since the assembler translates each instruction of an assembly language program into exactly one machine language instruction, assembly language programs are machine dependent.
That is, assembly languages differ from computer to computer, and we can execute an assembly language program only on the computer whose assembly language is the program’s code.
Hence, a decision to change to another computer will require learning a new language and converting all existing programs into the assembly language of the new computer.
 
2. Knowledge of hardware required: Since assembly languages are machine-dependent, an assembly language programmer must know their computer’s characteristics and logical structure to write good assembly language programs.
 
3. Machine-level coding: In the case of an assembly language, we still have to write instructions at a machine-code level. That is, one assembly language instruction corresponds to one machine language instruction. Hence, like machine language programs, writing assembly language programs are also time-consuming and challenging.
 

Typical Uses of Assembly Language

 
Programmers rarely write programs of any significant size in assembly language today. They write assembly language code only when a program’s execution efficiency is essential.
 
Assembly language programming helps produce compact, fast, and efficient code because it gives the total programmer control of the computer’s CPU, memory, and registers. Hence, we use assembly language programming mainly to fine-tune important parts of programs written in a higher-level language.
 

High-Level Language

 
A high-level language is a simple and user-friendly language that helps a programmer to read, write and maintain. It is similar to the English language, which enables people to write programs quickly in English. It is designed to be easier to use, more abstract, and more portable. Some popular high-level languages are C, C++, JAVA, BASIC, FORTRAN, etc.
 
The advent of high-level languages has enabled even non-expert users to use computers to solve problems. It has allowed many users without any background in computer science and engineering to become computer programmers. High-level language, in turn, has resulted in the creation of many computer applications in diverse areas leading to the use of computers today in every occupation.
 

Compiler

 
A computer can execute only machine language programs directly. Hence, we must convert a high-level language program into its equivalent machine language program before we can run it on a computer. We do this translation with the help of a translator program called a compiler.
 
A compiler is a translator program (more sophisticated than an assembler) that translates a high-level language program into its equivalent machine language program. A compiler is so-called because it compiles a set of machine language instructions for every program instruction of a high-level language.
 

Interpreter

 
An interpreter is another type of translator used to translate a high-level language program into its equivalent machine language program. It takes one statement of the high-level language program, translates it into machine language instructions, and then immediately executes the resulting machine language instructions.
 
An interpreter differs from a compiler that merely translates the entire source program into an object program and is not involved in its execution. The input to an interpreter is a source program, but unlike a compiler, its output is the result of program execution instead of an object program.
 
 

Compiler

Interpreter

It performs the translation of a program as a whole.

It performs the line-by-line translation.

Its execution is faster.

Its execution is slower.

It requires more memory as linking is needed for the generated intermediate object code.

It uses efficient memory as no intermediate object code is generated.

Debugging is difficult as the error messages are generated after scanning the complete program.

Debugging is easy as it stops translation when the first error is met.

Programming languages like C, and C++, use compilers.

Programming languages like BASIC, and Python use interpreters.

 

 

Merits of High-Level Language

 
1. Machine independence: We can execute a program written in a high-level language on many different types of computers with little or no effort in porting it to other computers.
 
2. Easier to learn/understand and use: High-level languages are easier to learn because they are very similar to the natural languages used in our daily lives. They are also easier to use because a programmer need not know the internal details of a computer for programming in a high-level language.
 
3. Fewer errors: While programming in a high-level language, a programmer need not worry about how and where to store the instructions and data of the program and need not write machine-level instructions for the computer. It allows the programmer to concentrate more on the logic of the program under development.
 
4. Lower program preparation cost: Writing programs in high-level languages requires less time and effort, ultimately leading to lower program preparation costs.
 
5. Better documentation: Statements of a program written in a high-level language are very similar to natural language statements used daily. As a result, very few or practically no separate comment statements are required in programs written in high-level languages.
 
6. Easier to maintain: Programs written in high-level languages are easier to maintain than assembly/machine language programs. Hence, we can incorporate significant changes in a program with minimal effort.
 

Demerits of High-level language

 
1. Lower efficiency: Generally, a program written in a high-level language has lower time and space efficiency than one written in a machine/assembly language to do the same job. However, with the advent of efficient and optimizing compilers, this problem is now becoming a non-issue.
 
2. Less flexibility: Generally, high-level languages are less flexible than assembly languages because they do not usually have instructions or mechanisms to control a computer’s CPU, memory, and registers.
 
The lack of flexibility means that a programmer cannot code some tasks or can code them only with great difficulty in a high-level language.
 
 

Leave a Comment