Write about Computer Languages/Programming languages

https://www.computersprofessor.com/2017/11/write-about-computer_8.html
Computer Languages/Programming languages
All computer programming languages fit into four general categories :
- Machine Language
- Assembly Language
- High Level Language
- Fourth Generation Language
- Machine Language
Although computers can be programmed to understand many different computer languages, every computer understands only one language without using a translation program. This language is called machine language of the computer. The machine language computer is written normally as strings of binary 1s and 0s. The circuitry of a computer is wired in a manner that it recognizes the machine language instructions immediately and converts them into electrical signals needed to execute them.
A machine language instruction normally has a two-part format . The first part is operation code that tells the computer what function to perform and the second part is operand that tells where to find or store the data to be manipulated. Hence, each instruction tells the computer what operation to perform and the length and locations of the data fields involved in the operation. Every computer has a set of operation codes called its instruction set. Each operation code (or opcode) in the instruction set is meant to perform a specific basic operation or function. Typical operations included in the instruction set of a computer are:
- Arithmetic operations
- Logical operations
- Branch operations (either conditional or unconditional) for transfer of control to the address given in the operand field.
Figure shows a typical single-address machine language instruction. Although some computers use only single-address instructions, many computers use multiple-address instructions that include addresses of two or more operands. For example, augend and addend may be the two operands of an addition operation.
All computers use binary digits (0s and 1s) for performing internal operations. Hence, most computers’ machine language instructions consist of strings of binary numbers. For example, a typical program instruction to print a number on a printer might be :
101100111111101100010000011111010
Machine Language programs have an advantage of very fast execution speeds and efficient use of primary memory. Use of this language is very difficult and time consuming method of programming. This language is said to be a low level language.
- Assembly Language
Assembly language falls in between machine language and high level language. They are similar to machine language, but easier to program in, because they allow the programmer to substitute names for numbers. The language uses mnemonics in place of 0s and 1s to represent the operation codes. The word mnemonic means refers to a memory aid. Assembly language programming was introduced in 1952 and helped in overcoming limitations of machine language programming by using alphanumeric mnemonic codes. For example, using ADD instead of 110 to add and SUB to subtract instead of 1111. It allows addresses of fixed storage locations to be represented by alphanumeric names instead of numeric addresses. For example memory location 1111, 1010 and 1001 may be represented as FRST, SCND, RSAN respectively in an assembly language program. With this feature, a programmer can remember easily and use the sorage location of the data nad instructions used in an assembly language program. It also provides additional instructions called pseudo-instructions, in the instructions set for instructing the system how we want the program to be assembled in the computer’s memory.
Although assembly language save time and reduce errors and find errors easily they have certain limitations:
i. Coding in this language is time consuming.
ii. This language is machine oriented i.e. they are designed for the specific make and model of processor being used.
Advantages of Assembly Language over Machine Language
i. Easier to understand and use
Due to the use of mnemonics instead of numeric op-codes and symbolic names for data locations instead of numeric addresses, assembly language programs are much easier to understand and use than machine language programs.
ii. Easier to locate and correct errors
Due to the use of mnemonic op-codes and symbolic names for data locations and also because programmers need not keep track of 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 automatically detect and indicate errors for use of an invalid mnemonic op-code or a name that has not been defined. 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 and not finding AREA in it will indicate the error.
iii. 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, insertion or removal of certain instructions in a program does not require change in the address part of the instructions following that part of the program. This is required in case of machine language.
iv. No worry about addresses
An important advantage of assembly language is that programmers need not keep track of storage locations of data and instructions while writing an assembly language program. For example, let us assume that we have written a long machine language program involving many instructions and several references to itself within the program such as looping, branching, and so on. At the very end, we suddenly discover that we have left out an instruction in the middle. If we insert that instruction, we will have to go through the entire program to check and modify (if necessary) all references to other instructions. This is certainly a tedious job. However, if we write the same program in assembly language, we merely add the extra instruction, and the assembler will take care of suitably modifying the references automatically.
v. Easily relocatable
The availability of pseudo-instructions for instructing the system how we want the program to be assembled inside the computer’s memory makes assembly language programs easily relocatable because their location can be easily changed by suitably changing the pseudo- instructions. This is not possible easily with machine language programming.
vi. Efficiency of machine language
An assembly language program also enjoys the efficiency of its corresponding machine language program because there is one-to-one correspondence between the instructions of an assembly language program and its corresponding 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.
Limitations of Assembly Language
Following limitations of machine language are not solved by using assembly language:
i. Machine dependent
Since each instruction of an assembly language program is translated into exactly one machine language instruction, assembly language programs are machine dependent. That
is, assembly languages differ from computer to computer, and an assembly language program can be executed only on the computer in whose assembly language it has been written. Hence, a decision to change to another computer will require learning a new language and conversion of all existing programs into assembly language of the new computer.
ii. Knowledge of hardware required
Since assembly languages are machine dependent, an assembly language programmer must have a good knowledge of the characteristics and logical structure of hislher computer to write good assembly language programs.
iii. Machine level coding
In case of an assembly language, instructions are still written at the machine- code level. That is, one assembly language instruction is substituted for one machine language instruction. Hence, like machine language programs, writing assembly language programs is also time-consuming and difficult.
Due to their limitations machine and assembly level languages are often refered to as low level programming.
Assembler
A computer can directly execute only machine language programs that use numbers for representing instructions and storage locations. Hence, an assembly language program must be converted (translated) into its equivalent machine language program before it can be executed on the computer. This translation is done with the help of a translator program called assembler. Assembler is a 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 main memory of the computer, and makes it ready for execution.
The following figure shows the process of translating an assembly language program into its equivalent machine language program by using an assembler. As the figure shows, input to the assembler is the assembly language program (often, referred to as source program), and its output is the machine language program (often referred to as object program). Since the assembler translates each assembly language instruction into an equivalent machine language instruction, there is a one-to-one correspondence between the assembly language instructions of a source program and the machine language instructions of its equivalent object program. Note that during the process of translation of a source program into its equivalent object program by the assembler, the source program is not under execution. It is only converted into a form that can be executed by the computer.
- High Level Language
These are languages whose instructions closely resemble human language and mathematical notation. Unlike assembly language, programs made in this language may be used with different makes of computers with little modification . Other advantages of high level languages are :
i. Easier to learn
ii. Required less time to write
iii. Provides better documentation
iv. Easier to maintain
As a result, high level language are used more often than machine or assembly languages. High level languages must also be translated into machine language before they can be used by computer. One of the two different language translator programs is used to translate high level languages: an interpreter or a compiler.
Few high level languages being used now a days are:
Logo, Ada, C, PASCAL, BASIC (Beginner’s All Purpose Symbolic Instruction Code), FORTAN (Formula Translator), COBOL (Common Business Oriented Language), PL/1 (Programming Language/ One), RPG (Report Program Generator, ALGOL (Algorithm Language).
Limitations of High Level Languages
i. Lower efficiency
Generally, a program written in a high-level language has lower efficiency than one written in a machine/assembly language to do the same job. That is, programs written in high- level languages result in multiple machine language instructions that may not be optimized, taking more time to execute and requiring more main memory Hence, when a program’s efficiency is important, its performance critical parts are written in assembly language and non-critical parts are written in a high-level language, However, with the advent of efficient and optimizing compilers this problem is now becoming a non-issue.
ii. Less flexibility
Generally, high-level languages are less flexible than assembly languages because they do not normally have instructions or mechanism to control a computer’s CPU, memory, and registers. An assembly language provides the programmers access to all the special features of the machine they are using certain types of operations that are easily programmed using the machine’s assembly language are impractical to attempt using a high-level language. This lack of flexibility means that some tasks cannot be done or can be done only with great difficulty in a high-level language.
Compiler
A complier translates a whole program (source coded) at once into machine language (object code) and then it can be immediately executed anytime thereafter. The source code remains intact and can be updated and then recompiled again into object code. Hence, a compiler is a translator program 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.
The following figure shows the process of translating a high level language into its equivalent machine language program using a compiler. As the figure shows, input to the compiler IS the high-level language program (often referred to as source program), and its output is the machine language program . Since high-level language instructions are macro instructions, the compiler translates each high-level language instruction into a set of machine level language instructions rather than a single machine language instruction. Hence there is one to many correspondence between the high level language instructions of a source program and the machine language instructions of its equivalent object program. Note that during the process of translation of a source program into its equivalent object program by the compiler, the source program is not under execution. It is only converted into a form that can be executed by the computer.
Interpreter
An interpreter is a translator which translates a program into machine language one line at a time and executes line of the program after it is translated The machine readable form of program is not stored on any storage and therefore, the program must be interpreted each time before it is executed. Therefore, in case of an interpreter, the translation and execution processes alternate for each statement encountered in high level language program. This differs from a compiler and merely translates the entire source program into an object program and is not involved in its execution. After compilation of a source program, the resulting object program is saved permanently for future use, and is used every time the program is to be executed. Hence, repeated compilation (translation of the source code) is not necessary for repeated execution of a program. However, in case of an interpreter, since no object program is saved for future use, repeated interpretation (translation plus execution) of a program is necessary for its repeated execution.
As compared to compilers, interpreters are easier to write because they are less complex programs than compilers. They also require less memory space for execution than compilers require.
The main advantage of interpreters over compilers is that a syntax error in a program statement is detected and brought to the attention of the programmer as soon as the program statement is interpreted.
5. Fourth Generation Languages (4GL)
The machine, assembly and high level languages are given ‘generation’ designation by some people in the computer field. Machine languages are considered first generation, assembly languages are second generation and high level languages are third generation languages. Fourth generation languages are those which allow users to create programs with much less effort than what is required by other languages.
Examples include – Prolog, SQL, MySQL etc.
Important Points
- PASCAL programming language was designed by Niklaus Wirth in 1971.
- FORTAN was developed by a team of programmers by IB led by John Backus in 1957.
- BASIC was designed by John G. Kemeny and Thomas E. Kurtz in 1964
- The initial work on the design of COBOL was stated in 1959 under the leadership of Grace Hopper.
- C language was developed in 1972 at AT and T’s bell laboratories, USA by Dennis Ritchie and Brain Kernighan. A new version of C++ was developed by Bjarne Stroustrup at Bell Labs in the early 10980s.
- Java another high level language was developed by a team led by James Gosling. The language was formaly announced in May 1995 and its first commercial release was made in early 1996. Java uses the concept of just in time complilation.
- RPG another high level language which stands for Report Program Generator. IBM developed the language and launched in 1961 for use on the IBM 1401 computer.
- SNOBOL stands for String Oriented Symbolic Language. It is another language for non numeric applications.
- LISP stands for List It was developed in 1959 by John McCarthy of MIT. His goal was to develop a language that is good at manipulating non-numeric data such as symbols and strings of text. Such data handling capability is needed in compiler development, and in Artificial Intelligence (AI) applications.