A computer program is a set of instructions that performs a specific task when executed by a computer. A computer requires programs to function and typically executes the program’s instructions in a central processing unit. A computer program is usually written by a computer programmer in a programming language.
SYNTAXIN PROGRAMMING LANGUAGE:
Syntax refers to the rules that define the structure of a language. Syntax in computer programming means a set of keywords and characters that a computer can understand, interpret and perform task associated with them. The syntax of a language must be followed, and if it is not followed, the code will not be understood by a compiler or interpreter. Different programming languages have different types of syntax.
CLASSIFICATION OF PROGRAMMING LANGUAGE:
Based on the accessibility of hardware, programming languages can be classified into the following categories: 1. Low-level language 2. Middle-level language 3. High-level language
LOW-LEVEL LANGUAGE:
Low-level programming languages are those languages that are directly communicated with computer hardware. The two languages come under this category are Machine language and Assembly language.
MACHINE-LEVEL LANGUAGE:
Machine language is a collection of binary digits or bits that the computer reads and interprets. This language is the only language understood by computers while machine language is almost impossible for humans to use because they consist entirely of numbers (Os & 1s). Machine code doesn’t require translator because machine code is directly executed by computer. It is also called first generation language.
ASSEMBLY LANGUAGE:
A program written in assembly language consists of a series of instructions called mnemonics that correspond to a stream of executable instructions. Assembly language code is translated by a translator called assembler. Assembly language uses keywords and symbols much like English and are easy to read, write and maintain as compared to machine language. It is also called second generation programming language.
MIDDLE-LEVEL LANGUAGE:
The middle-level language lies in between the low level and high-level language. Middle- level language actually binds the gap between a machine level language and high-level languages, these languages are now become obsolete and are not in used.
HIGH-LEVEL LANGUAGE:
High-level languages are relatively new and drastically revolutionized the programming world. It allows us to write computer code using instructions resembling everyday spoken language, usually English (for example: print, if, while). Programs written in a high-level language need to be translated by a translator (compiler or interpreter) into machine language before execution.
ADVANTAGES OF IDGH-LEVEL LANGUAGE:
Low Level Language
⦁ In low level language machine codes (0 and 1) are used as an instruction to the computer. ⦁ The execution of programs is quite fast. ⦁ Instructions are directly understood by the CPU ⦁ No need to translate program. In case of assembly language assembler is required. ⦁ The programs written in low level languages are machine dependent and are difficult to modify. ⦁ The examples of low-level languages are: (1) Machine language (2) Assembly language
High Level Language
⦁ In high level language English like words are used as an instruction to the computer. ⦁ The execution of programs is not very fast. ⦁ Instructions are not directly understood by the CPU ⦁ Translation of program is required. ⦁ The programs written in high level languages are machine independent and are easy to modify. ⦁ The examples of high-level languages are: BASIC, FORTRAN, COBOL, PASCAL, C languages etc.
TRANSLATORS OR LANGUAGE TRANSLATORS
Language translator is a computer program that converts high level language program into low level program (1s & 0s), or machine language. It transforms the source code into the object code (machine code) which understands directly by the computer processor. Translators also detect and report errors in the process of translation. There are three types of language translators. * Interpreter * Compiler * Assembler
COMPILER:
Compiler is a program that translates the high-level language program into machine language. Compiler translates the whole program at a time at once before it executed and makes a separate object file for the translated program. Translated program can be used multiple times without the need of retranslation of source codes. Each high-level language has its own compiler.
INTERPRETER:
Interpreter is a language translator program, which converts high level program into machine language. It translates one instruction at a time. Interpreter does not make any object file and it translates the program every time when executed. An interpreter is faster than a compiler as it immediately executes the codes.
ASSEMBLER:
An assembler is a translator that converts assembly language program into machine language. An assembler translates assembly language code directly into machine code that can be understood by the CPU.