You are on page 1of 13

COLLEGE OF INFORMATION TECHNOLOGY UNIVERSITI TENAGA NASIONAL SUBJECT: MITM623

Assignment 4 : Object Oriented Language Vs Imperative Language

GROUP MEMBER: 1. 2. Firas Zaki Hadi : ST21331 Rubahdevi : ST21070

Lecturer: Dr. Roslan Date Submission: 2nd September 2013


1

Table of Contents
1.0 2.0 Introduction to Programming Language Paradigm .................................................................... 3 Similarities and Diffrences between OOP and Imperative Language ......................................... 4

3.0 Comparison of Readability, Write ability and Reliability between OOP and Imperative Language. ................................................................................................................................................ 7 4.0 5.0 Adoption and Usage of both Language in IT Community ......................................................... 12 Latest Development of OOP and Conclusion ............................................................................ 13

1.0

Introduction to Programming Language Paradigm

Programming language paradigm is divided into four main criterias which is the object oriented programming (OOP), imperative programming, structural programming and the logic programming. In this assignment we are instructed to compare between the object oriented programming and the imperative programming. First let us briefly explain about OOP. OOP is a language that defines data type in a data structure which then gives importance to the operations or the functions. In another word, OOP characterize the concept of an Object from a Class which has data types or Attribute which is associated with the Methods or the procedure. A very common OOP language that is being widely used today is the Java and C ++. The OOP was introduced in SIMULA 67 but then it was not fully developed until there was the Smalltalk evolution. The commonly used features in OOP are the inheritance, dynamic bindings, recursion, encapsulations and polymorphism.

Figure 1: Object Oriented Structure

As of for imperative language, it is commonly said as procedural programming or a structural programming. Imperative language is the first language which was designed years back and is still being used for its write ability and readability purpose. This language mainly describes on a computation statements or terms which changes a program. The natural language used in the codes is usually the expressive commands which eventually do the action. These imperative later, compiles the codes of expression in sequence format which later run by the computer. The common imperative language which is being used is FORTAN and Imperative Language.

2.0 Similarities and Diffrences between OOP and Imperative Language


Similarities between both the languages: 1. Direct assignments statements

Assignments mean ways of using an expression which uses operators. For example operators such as &, ||, >= , <= are being used in both the languages. Moreover, there is no other way of expressing a value in a computational statement. 2. Common data structures

Data structure is where a data is being fetched and stored in a computers memory which it is eventually specified by an address / string. To store the data in the memory, data procedurers are being used. The commonly used data procedures is the arrays data structure, record, hash, binary etc is being commonly used by both the languages. 3. Global variables

Usage of global variable is very important in a programming language. It is actually a set of variables which are globally used in an application. Below is an example of an global variable used:

Differences between both the languages: 1. Class, Objects and Methods

A class is a type of object and an object of a same type will be in the same class. An object is a program that constructs and contains specific datas. This datas then can perform certain

actions. This action is called the methods. When a programmer invokes an action, the program runs the method. 2. Message passing,

Message passing is a concept of a communication routine where the message is being sent from a sender to one or more receptions. There are many kinds of message passing tools and it is designed according to the OOP languages. The distributed object and remote method invocation systems like ONC RPC, CORBA, Java RMI, DCOM, SOAP, .NET Remoting, CTOS, QNX Neutrino RTOS, Open Binder, D-Bus, Unison RTOS and similar are message passing systems. 3. Information hiding,

Information hiding is where certain class, objects or methods are being hide from the view of the programmers. It is like a static variable which is being hide so that It will not change the current application system. For example is the interface of a client. If certain information is changed in this statement it many affect the whole interface. Therefore the main statements or variable will remain as hided due to some policy or protected reason. 4. Encapsulation,

Encapsulation is where a code is designed to enclose a data and methods with in the class .By doing this a programmer only can receive certain information in using the class. Therefore, this is a part of information hiding and data abstraction method in revealing certain informations. For example the below C language shows that the balance can be check but cant change the value of the account balance.

6.

Polymorphism,

Polymorphism where the values in certain scope can be used in another scope. It is another way of message passing method. Below is an example in a Phyton language of a polymorphism.

7.

Inheritance,

Inheritance is where objects are defined in classes. Usually statements can be inherit from few classes such as the base class, super class and the parent class. The reason of inheritance is to create hierarchy in OOP languages..

3.0 Comparison of Readability, Write ability and Reliability between OOP and Imperative Language.
Readability against a programming language means a programming language (PL) should be easy to be read and understand by a programmer. Readability consists of few evaluation criteria as per below: 1. The overall simplicity of a PL A PL should have manageable sets of features and constructs. Compared to OOP and Imperative Language, Imperative Language have got better manageable sets of features and constructs. Imperative Language features and constructs are very easy to be understood as it used basic words such as Begin to begin a syntax, Read used to process a word, Write to display comment on screen for inputect. Unlike OOP its uses cout to display the output stream with (;) at the end , cin to refer standard input stream and istream which is a input stream for syntax which consist of classes. Hence, it should also have minimal features of multiplicity and minimal operator overloading. Imperative Language has minimal features of multiplicity and operator overloading compared to OOP and it can reduce the tolerance of a programmer making errors. OOP is object oriented which shares many routines in different sets and extensible whereby Imperative Language is structure oriented as it has no interpretation. As per operator overloading, Imperative Language has got less operators compared to OOP. Example, Imperative Language operators are and, or, not where else OOP are more arithmetic &&, ||, == 2. Orthogonality Orthogonality in PL means when a small set of a primitive construct which can be easily combined in numerous different methods. In another meaning a PL or a data object can be used without considering its after effects towards other program functions. Usually too much orthogonality may cause problems. Imperative Language is to be considered as orthogonal and OOP is as nonorthogonal. Generally, Imperative Language has got sets which can be easily compiled and its priority is on mathematical statements. As of OOP it is said to be non orthogonal as it is an object oriented language which consist of arrays, tables, listect. Usually, an integer can be converted into a float by assigning a float to an integer but it cant be done the other way round. Arrays are usually passed by its references and an integer is passed by its value. Where else a switch statement can be practically used in integers, characters and enumerator types. Hence it cant be used on double or string in OOP.

3. Data types and control statements Tolerable and adequate predefined variables data types and control statement. Both the Imperative Language and OOP has got its own predefined data types but Imperative Language has less data types and control statements compared to OOP.
7

For example Imperative Language has got only integer, real, boolean, char and string where else OOP has got additional data types such as long int, wchar_t, short int ect. As of control statement, for example, in Imperative Language the case statement , was enhanced by OOP with the aid of switch statement.

4. Syntax considerations As of the syntax consideration, Imperative Language is more flexible to be written then OOP as the forms and meaning are self descriptive and have got easy, understandable keywords compared to OOP. Imperative Language to be mentioned as direct identifier because it does not allow underscore identifier unlike OOP. It is easier for a programmer to understand the meaning of an identifier in full word rather than having underscore which can be confusing. Another example on syntax consideration, is the Compound statements, statements groups in Imperative Language language consist BeginEnd. In OOP: {}sometimes it is difficult to determine which statement groups is being ended. Hence, in Imperative Language, there is only one End with point put to end program. This End is to declare the end of the program. In conclusion about readability, we noticed in the first C + + program that contains 10 steps for the implementation of the equation and it is actually difficult for the new user to remember all statements because it does not have any meaning in the English language like cin and cout. Where else, the second Imperative Language program which contains only 7 sentences are simple. This code/words per say are all taken from the English language (such as reading, writing, start) which is also easy to be remembered. Hence, we have also did a survey by asking few of the undergraduate students who are not aware of both OOP and Imperative Language language. Generally, we found that the student understands Imperative Language statements better compared to OOP. b. Writability : Writability is a way of measure on how easily a programming language can be written in creation of a program or project. In addition, the languages which characterize readability has the same affect and rely on writability. Which means there inter-related commonly. Writability also must be considered in the context of the problem domain of a language. For example, there is a set data type in Imperative Language which makes it easier to handle set operations as compared to a language such as OOP where this support is not available. Example: the loop in Imperative Language (for i:=1 to 3) but in OOP(for i=1,i=3,i++) 1. Simplicity and Orthogonality
8

The same concept in readability applies to writability. A PL should be simply to be written and orthogonal. Likewise mentioned above, Imperative Language is much easier to write and orthogonal then OOP. Below are the examples of Imperative Language and OOP, when we compare both the language Imperative Language has got fewer steps to be written compared to OOP. OOP is assumed to be rather complicated. For example below are program codes to calculate the sum of two numbers both in OOP and Imperative Language OOP code (C++) #include<iostream.h> main() {int rst, seconds, sum; cin>> rst; cout<<"+\n"; cin>> seconds; sum= rst+ seconds; cout<<"---------\nsum="<< sum ; } Imperative Language code (Pascal) var a,b,:integer; begin read (c,f); d:= c + f; write (d); end. 2. Support for abstraction Imperative Language is very complex low level structured language that the operations in the syntax can be easily written and understood by any other programmers. Usually structured language is very easy to be written as its direct to the point. Unlike OOP which is a object oriented language and is considered as high level language which consist of encapsulation, inheritance and polymorphism. 3. Expressivity Expressivity is an easy way in conveying a set of operations. The operation includes the strength and the popular usage of operators and predefined functions in a programming language. Both languages (OOP and Imperative Language) are Expressivity are very strong For example in C++, some expression such as increase operator (++) or decrease operator (--) is used for increasing of a value or decreasing of a value. This is as same as +=1 and to -=1 comparatively. Thus: ++ f; f+=1; f = f+1;

Also Imperative Language has got few easier operations such as For...repeat,..while. In addition, when it comes to loop expression, Imperative Language is easier to be written compared to OOP which has got post increment as per below statement: For example in Imperative Language For i: =1 to 100 In OOP For (i=1;i=100;i++) In conclusion for writability, it is easier for a programmer to write using Imperative Language compared to OOP as Imperative Language is a structured language which has clarity and easier to be maintained. A non-structured language like OOP can be hard to write as well as hardly readable. c. Reliability: Reliability is where a program performance is up to the specification without any errors and can be used over and over again. 1. Type checking Checking for any syntax error at the beginning of the coding is called the type checking. Both OOP and Imperative Language has got its type checking when it comes to compilation. This minor syntax error can be earlier detected when a programmer either compiles the code or run the code. For example, if the double is written as doub in Imperative Language, when a programmer compiles, there will be an error message just like OOP 2. Exception handling Likewise, both the language have got exception handling. Below are the examples of exception handling for both OOP and Imperative Language. Below are the constructs used for Imperative Language exception handling: Raise statements: This is used to highlight an error in a condition rule and to bring up an exception. Try ... Except blocks : This is usually used within a scope to prompt an exception. Try ... Finally blocks. : This is usually used to clean up the memory in many closed files. This is to make sure that the memory is used consistently. Example exception handling for Imperative Language Pascal language: Var F : Text; begin Try Assign (name); Rewrite (name); File handling Finally Close(F); end;

10

Throw: Usually a program is then thrower when there is an exception by using a specific keyword. Catch: This catch statement usually catches an exception where in a scope or a block that a programmer wants to handle certain problem. Try: Usually used in a block to try an exception or to see any values in that certain scope.

Example of exception handling for OOP #include <iostream> using namespace std; double division(int d, int w) { If ( d == 0 ) { throw "Division by zero condition!"; } return (d/w); }

3. Readability and Writebility As mentioned above, Imperative Language is much more easier to be read and write by a programmer compared to OOP whereby a programmer need to be familiar with each and every syntax, constructs of OOP. Unlike, Imperative Language, the syntax and statements are straight to the point. In overall conclusion, Imperative Language is a structured language, and OOP is a object oriented language. Both the languages have got own advantages and disadvantages. In general, through, readability, writability and reliability, we assume that, Imperative Language is an easy language can be read, understood, write and relay compared to OOP which is very object oriented and hard to be understood. Even though, Imperative Language is considered as a low level PL, it is a better choice for most of the programmers to compromise with it. It can be also developed faster and easier to be maintained compared to OOP.

11

Figure 3 : Shows a common way of writing the same code in a OOP language and in an imperative language

4.0

Adoption and Usage of both Language in IT Community

OOP is very commonly used in building an application mainly due to its reliability and maintainability. The language that is ranked as no 1 among the IT community is the Java language. It is to be said that Java is the strongest application used due to many specific reason. Upon goggling on Java language, we got to kow that this oop language is ranked at no 1 for the coming next 10 to 15 years to come by TIOBE. This shows that this oop language is widely, commonly used by developers in their development and is being the largest application developed and installed. There seems to be no sign of declining in the usage of Java language. Java is commonly used in the front end especially in the enterprise solutions. Since Java is a standardized version, it can be merely passed over to many different programmers and they can indeed do programming well. It is actually a verbose OOP language. Apparently, must the companies are using Java as their preferred language because they know that this language can live up to the next 15 years and easily can achieve their companies goals and target. Mos of the IT giants are supporting the Java language. I assume that is the main reason why the other languages are having heavy tough competitions oppose Java OOP language. Companies such as Google, Oracle, IBM, the Apache Software Federation etc support the language since it is more reliable and portable. Technology user such as banks and various industries also rely on this OOP language. Its like no other language have such support towards its development. Talking about portability, Java is easy convertible and adjustable to
12

various platform. For example, the mobile platform is now using Java in the name of Android. There are very less language that has these same portability and credibility. This is due to its language which cans inherit from one platform to another with its wide usage and creation of libraries.

5.0

Latest Development of OOP and Conclusion

The latest development in OOP is the android. Android uses Java tools such as Java languages, libraries, Java Script and many more. Android is mainly used in smart phones, IOS and most of the high level games software application. If we do a little research on these areas, we could able to see that the applications are improving as the gaming standard grows. There are more and more new IT gadgets are being invented and introduced to the world. The special recognition always goes to the founder of OOP language that too the Java. Regardless to the application software designing tools, Java own excellent tools such as the Netbeans, Elispse. It is so easy for developers to develop an application with the help of such tools and it can apparently increase their productivity and innovation. There are also many Java open source such as the Open JDK for people around the world to share the libraties. Eventually, there are more to more to come on board so lets wait for the future! Java is an OOP language thats "simple, object oriented, and familiar".

13

You might also like