Understanding & Evolution of OOP

Lectures 3-5

Programing Language paradigms influencing programing language design and implementation

Program is sequence of statements. Following are the types of programing languages:

1. Imperative : It is programming with side effects. The result of a function depends on the history and state of program.

        e.g.         x = 5 ;

                y = f(x);

                x = 10;

                y = f(x);

Here value of function depends on state of x.

2. Declarative : It is programming with only declarations like y = f(x). It only tells what is value of y but does not tell how to compute it.

3. Logical : It is programming based on logic.

e.g. LISP

4. Functional : Pure functional language is programming without side effects. The result of a function is independent of history and state of program. It can be declarative.

e.g. Haskell

5. Scripting : It is programing to do the things quickly without following much rules.

e.g. Python

6. Object Oriented : It is imperative programming. The result of a function depends on the history and state of program. Hence verification becomes difficult for imperative languages.

One programming language can have more than one paradigms. It is called impure language, impure does not mean bad but mix of paradigms. It has its own pros and cons.

e.g. Python and Java - Object Oriented, Imperative, Scripting

More on Cā€¦

Evolution of object oriented programming from C

1. Procedural : It is language that contains procedures. e.g. C

    Procedure: It is sequence of statements with some name.

    Opposite of procedural language is flat language. e.g. old assembly language

2. Structural : It is language that has structures like procedures.

3. Modular : It is language that contains modules.

    How is a module different from a procedure ?

   It puts all related things in one module. Interdependency between the modules is minimised, i.e. modules are loosely coupled. Structs in C makes it modular.

4. Data Abstraction : It means to define our own data type and its behaviour. In C we achieve this by defining a structure with data fields and functions that apply on it.

e.g.In C structure stack can be implemented as an array with functions like push and pop.

5. C with Classes : Here we make a module as class. e.g. stack module as stack class. It is still not object oriented language.

6. Parameterised type : It is language that supports functions which can have types as their parameters.

Synergy of PLDI with Software Engineering

  1. Open Close system
  2. Separate interface and implementation

        Code1: int ary[100];

  for (int i = 0; i < 100; i++)

do_something();

Code 2: int [] ary = new int (100); // int ary [] ā€¦

   for (int i = 0; i < ary.length; i++)

do_something();

What is difference in above 2 code snippets?

Evolution of OOP continue..

Issues to be addressed