× Back What is programming language? What is POP and OOP OOP concepts Generation of programming language
← Previous Topic

Programming Model

What is programming language?

The programming languages can be classified into two types -
1. Low level languages
2. High level languages

Low level languages

The languages in this category are the Machine level language and Assembly language.

Machine Level Language

  • Computers can understand only digits signals, which are in binary digits i.e. 0 and 1.
  • So the instructions given to the computer can be only in binary codes.
  • The machine language consists of instructions that are in binary 0 or 1.
  • Computers can understand only machine level language.
  • Writing a program in machine level language is a difficult task because it is not easy for programmers to write instructions in binary code.
  • A machine level language program is error-prone and its maintenance is very difficult.
  • Furthermore machine language programs are not portable.
  • Every computer has its own machine instructions, so the programs written for one computer are not valid for other computers.

Assembly Language

  • The difficulties faced in machine level language were reduced to some extent by using a modified form of machine level language called assembly language.
  • In assembly language instructions are given in English like words, such as MOV, ADD, SUB etc. So it is easier-to write and understand assembly programs.
  • Since a computer can understand only machine level language, assembly language program must be translated into mahcine language.
  • The translator that is used for translating is called 'assembler'.
  • Although writing programs in assembly language is a bit easier, the programmer has to know all the lower level details related with the hardware of a computer.
  • In assembly language, data is stored in computer registers and each computer has diiferent set of registers. Thus the assembly language program is also not portable.
  • Since the low level languages are related with the hardware, the execution of a low-level program is faster.

High level language

  • High level languages are designed keeping in mind the features of portability i.e. these languages are machine independent.
  • These are English like languages, so it is easy to write and understand the programs of high-level language.
  • While programming in a high level language, the programmer is not concerned with the low level details, and so the whole attention can be paid to the logic of the problem being solved.
  • For translating a high-level language program into machine language, compiler or interpreter is used.
  • Every language has its own compiler or interpreter.
  • Some languages in this category are- C, FORTAN, COBOL, BASIC, Pascal etc.

Translators

  • Translators are just computer programs, which accept a program written in high level or low-level language and produce an equivalent machine language program as output.
  • The three types of translators used are-
    -Assembler
    -Compiler
    -Interpreter

Assembler

  • It is used for converting the code of low-level language (assembly language) into machine level language.

Compiler and interpreters

  • Both are used to convert the code of high-level language into machine language.
  • The high level language is known as source program and the corresponding machine language program is known as object program.
  • Although both compilers and interpreters perform the same task, there is a difference in their working.

Compiler and Interpreter

  • A compiler searches all the errors of program and lists them.
  • If the program is error free then it converts the code of program into machine code and then the program can be executed by separate commands.
  • An interpreter checks the errors of program statement by statement.
  • After checking one statement, it converts that statement into machine code and then executes that statement.
  • This process continues until the last statement of program or an erroneous statement occurs.

What is procedural and object oriented programming?

Procedural programming

  • It deals with algorithm.
  • Program are divided into functions.
  • It needs less memory.
  • It is concept of top down approach.
  • overloading is not possible.
  • Less secure
  • Data hiding is not possible.
  • It can be defined as a programming model which is derived from structured programming, based upon the concept of calling procedure.
  • Procedures, also known as routines, subroutines or functions, simply consists of a series of computational steps to be carried out.
  • During a program's execution, any given procedure might be called at any point, including by other procedures or itself.
  • Languages used in Procedural Programming:
    → FORTAN, ALGOL, COBOL, BASIC, PASCAL and C.

Object Oriented

  • It deals with data.
  • programs are divided into objects.
  • Need more memory.
  • It is concept of bottom up approach.
  • overloading is possible → Function and operator overloading.
  • Highly secure.
  • Data hiding is possible.
  • It can be defined as a programming model which is based upon the concept of objects.
  • Objects contain data in the form of attributes and code in the form of methods.
  • In object-oriented programming, computer programs are designed using the concept of objects that interact with the real world.
  • Object-oriented programming languages are various but the most popular ones are class-based, meaning that objects are instances of classes, which also determine their types.
  • Languages used in Object-Oriented Programming:
    → Java, C++, C#, Python, PHP, JavaScript, Ruby, Perl, Objective-C, Dart, Swift, Scala.

The basic Object-oriented programming concepts are :

Inheritance

  • Inheritance can be defined as the process where one (parent/super) class acquires the properties (methods and fields) of another (child/sub). With the use of inheritance, the information is made manageable in a hierarchical order.

Polymorphism

  • Polymorphism is the ability of an object to perform different actions (or, exhibit different behaviors) based on the context.

Abstraction

  • Abstraction is a process of hiding the implementation details from the user, only the functionality will be provided to the user. In other words, the user will have the information on what the object does instead of how it does it.
  • In Java, abstraction is achieved using Abstract classes and interfaces.

Encapsulation

  • Encapsulation in Java is a mechanism for wrapping the data (variables) and code acting on the data (methods) together as a single unit. In encapsulation, the variables of a class will be hidden from other classes and can be accessed only through the methods of their current class. Therefore, it is also known as data hiding.

Generation of programming languages

First Generation

  • The first-generation languages are also called machine languages/1G language.
  • This language is machine-dependent.
  • The machine language statements are written in binary code (0/1 form) because the computer can understand only binary language.

Advantage

  • Fast & efficient as statements are directly written in binary language.
  • No translator is required.

Disadvantages

  • Difficult to learn binary codes.
  • Difficult to understand-both programs & where the error occured.

Second-Generation Language

  • The second-generation languages are also called assembler languages/2G languages.
  • Assembly language contains human-readable notations that can be further converted to machine language using an assembler.
  • Assembler → converts assembly level instructions to machine-level instrucitons.

Advantages

  • It is easier to understand if campared to machine language.
  • Modificaitons are easy.
  • Correction & locaiton of errors are easy.

Disadvantages

  • Assembler is required.
  • This language is architecture/machine-dependent, with a different instruction set for different machines.

Third-Generation Language

  • The third-generation is also known as procedural language/3G language.
  • It consists of the use of a series of english-like words that humans can understand easily, to write instructions.
  • It's also called high-level programming language.
  • For execution, a program in this language needs to be translated into machine language using a compiler/interpreter.
  • Example → C, PASCAL, FORTAN, COBOL, etc.

Advantages

  • Use of english-like words makes it a human-understandable language.
  • Lesser number of lines of codes as compared to the 1G and 2G languages.
  • Same code can be copied to another machine & executed on that machine by using compiler-specific to that machine.

Disadvantages

  • Compiler/interpreter is needed.
  • Different compilers are needed for different machines.

Fourth Generation Languages

  • The fourth-generation is also called a non-procedural language/ 4GL.
  • It enables user to access the database.
  • These languages are also human-friendly to understand.
  • 4GLs are designed to reduce the overall time, effort and cost of software development.
  • Exmaples → SQL, Focus, etc.

Advantages

  • Easy to understand & learn.
  • It reduces overall cost, time, and effort.
  • A single line command can perform the task. On the other hand, in other languages, we need to write a series of commands for the same task, in which syntax and keywords are not easily understandable.
  • As databases are used everywhere to manage data so 4GL makes it very easy to create, manage and operate the database.
  • It is very easy and simple to use even for beginners or end users.
  • Less time is required for application creation.
  • It is less prone to errors.

Disadvantages

  • Memory consumption is high.
  • This is easy for users but in backend each query executes a sequence of commands which makes it time consuming.
  • This language is only database oriented, which means we can use it for databases only.
  • Has poor control over Hardware.
  • Less flexible.

Fifth-Generation Languages

  • The fifth-generation languages are also called 5GL.
  • It is based on the concept that rather than solving a problem algorithmically, an application can be build to solve any problem.
  • Example → LISP, PROLOG, etc.

Advantages

  • Machines can make decisions.
  • Programmer effort reduces to solve a program.
  • Easier than 3GL or 4GL to learn and use.

Disadvantages

  • Complex long code.
  • More resources are required & they are expensive too.

References