Sunday, July 12, 2020

Languages & Its Classifications

 

What is a Language?
L(G) is a language defined under the grammar(Constants, Variables & Rules) G, to communicate between objects. 

The objects may be 
  1. Homogeneous objects (person to person) or 
  2. Heterogeneous objects(person to animal, person to machine).
Mathematically we can say any language L is defined by a grammar G, denoted by L(G), where G can be defined as a four tuple (Vn, Vt, P, S), where,
  • Vn : Set of Variables.
  • Vt : Set of Constants.
  • P  : Rules of Production of Sentence/ Statements.
  • S  : An Element of Vn from where every production will start.

Classifications of Languages:
Languages can classified as follows:
  1. General Life Languages
    1. Written Languages: English, Bengali, Hindi etc
    2. Verbal Languages: English, Bengali, Hindi
    3. Symbolic Languages: Used by the peoples who can not hear or talk or write at all
  2. Languages for Machine: Our main objective is to learn languages to instruct machines
    1. Programming Languages: Requires translator(Compiler/ Interpreter)
      1. High Level Languages
        1. Procedural Languages: C, FORTRAN, COBOL, PASCAL
        2. Object Oriented Languages: BASIC, C++, Java, Python
      2. Assembly Languages: Requires translator(Assembler)
      3. Low Level Languages
    2. Scripting Languages: HTML, ASP, Java Script, Shell Script
Translators: There are different translator for high level/ assembly level languages, which translates the program code written in high/ assembly level languages into respective machine level program code so that machine can understand the instructions given.

Compiler: A translator for high level language to low level language. It takes the entire program code and after translation it produces low level program code(object code), which can be executed any time when required without further compilation, only linking & loading is required. gcc, cc are the standard C compiler. g++ is the standard C++ compiler. FL is the standard FORTRAN 90 compiler. javac is the standard compiler for translating java programs into respective byte code language.

Interpreter: It is a translator that takes line by line code, translates it into low level code & executes the code before moving to next code. This is architecture independent process but slow process with respect to a compiled code. To execute the program, the system must have the interpreter installed on it. The code must be translated every time. Translated code is not reusable. java is a standard interpreter for Java byte code programs. qbasic/ gwbasic are the standard interpreter for BASIC. py is the standard interpreter for Python.

Assembler: It is the translator of assembly language to its equivalent low level program. asm, tasm, masm are the standard x86 assembler.

In Object Oriented Programming C++ and Java are widely used to explain/ implement the concepts. C++ is compiler based language but Java is based on interpretation.


Programming in C follows:
  1. Write the program file and save it as Program_Name.c
  2. Compile  as gcc Program_Name.c. This step will create a.out file(default) or a file with .out extension as specified by the programmer.
  3. Execute as ./a.out from terminal(command line)
 
Programming in Java follows:
  1. Write the program file and save it as Program_Name.java
  2. Compile for byte code as javac Program_Name.java. This step will create .class files, one for each class in the program code.
  3. Execute as java Main_Class, which is the main class from where main() function has been called.


Programming in C++ follows:
  1. Write the program file and save it as Program_Name.cpp
  2. Compile  as g++ Program_Name.cpp. This step will create a.out file(default) or a file with .out extension as specified by the programmer.
  3. Execute as ./a.out from terminal(command line)
(All the notations stated above are for Linux/ Unix based Operating System)