object-oriented programming languages (oopls) an introduction

22
Object-Oriented Programming Languages (OOPLs) An Introduction

Upload: reynard-phillips

Post on 12-Jan-2016

220 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Object-Oriented Programming Languages (OOPLs) An Introduction

Object-Oriented Programming Languages (OOPLs)

An Introduction

Page 2: Object-Oriented Programming Languages (OOPLs) An Introduction

What is an OOPL

No clear definition of what an OOPL is as there is no formal theory of OO

(unlike logical or functional programming,

or relational model)

Most people agree on OOPL = class based + inheritance

Page 3: Object-Oriented Programming Languages (OOPLs) An Introduction

Background

Time efficiency bottlenecks associated with implementation of encapsulation and information hiding inheritance and polymorphism

Related Programming Language Concepts Garbage collection Static versus Dynamic Typing

Page 4: Object-Oriented Programming Languages (OOPLs) An Introduction

Garbage collection

A is a mechanism allowing a language implementation to free memory of unused objects on behalf of the programmer, thus relieving the burden on the programmer to do so. The alternative is for the programmer to explicitly free any memory that is no longer needed.

Occurs whenever memory becomes full – timing is unpredictable

Can take fairly substantial time

Page 5: Object-Oriented Programming Languages (OOPLs) An Introduction

Static versus Dynamic typing: robustness versus flexibility

Static Statically-typed languages require that all variables are declared with a specific

class, and then the variable can contain objects of that class or any of its subclasses.

Under static-typing errors associated with misuse of services ("message not understood" error) are caught at compilation-time and can never occur at run-time.

DynamicUnder dynamic typing a variable to refer to an object of any class. Dynamic typing gives the programmer more flexibility.

However, a user of a dynamically-typed language must rely on extensive testing to ensure that all improper uses of the object are tracked down.

Page 6: Object-Oriented Programming Languages (OOPLs) An Introduction

Overview

Simula 67 – 1967

Smalltalk – 1970’s

C++ - 1986

Eiffel -1990

Java –1990’s

Page 7: Object-Oriented Programming Languages (OOPLs) An Introduction

Simula 67

Introduced classes and hierarchical inheritance for the first time

Motivated by a simulation application

Still has active users

Authors: Dahl and Nygaard

Page 8: Object-Oriented Programming Languages (OOPLs) An Introduction

Simula 67 - Features

Typing Hybrid (static/dynamic)

Polymorphism Yes

Information Hiding Yes

Concurrency Yes

Inheritance Yes

Multiple Inheritance No

Garbage Collection Yes

Object Persistence No

Genericity No

Page 9: Object-Oriented Programming Languages (OOPLs) An Introduction

Smalltalk

Widely considered to be the purest representation of the OO paradigm: Everything is an object (even numbers) Single Superclass

Authors: Kay, Goldberg, Ingalls et al. from Xerox PARC

Page 10: Object-Oriented Programming Languages (OOPLs) An Introduction

Smalltalk - summary of features

Typing Dynamic

Polymorphism Yes

Information Hiding Yes

Concurrency Poor

Inheritance Yes

Multiple Inheritance No

Garbage Collection Yes

Object Persistence No

Genericity No

Page 11: Object-Oriented Programming Languages (OOPLs) An Introduction

Smalltalk: pros and cons

Pros Conceptually uniform Great pedagogical tool:

Impossible to write anything in a non-object-oriented style

Superb run-time environment: debugging, class browsing

Cons Memory and time

inefficiency Message-errors can be only

detected at run- time Hard to integrate with other

languages (prior to CORBA)

Unusual syntax awkward for many developers

Page 12: Object-Oriented Programming Languages (OOPLs) An Introduction

C++

Upward compatible extension of C. Classes are added as a new primitive data type but can as well ignore all OO features

Designed with portability and efficiency in mind

Compromise between the pragmatism and the object-oriented ideal gives low level control over hardware when required benefits of object-orientation when required and enforced

Author: B. Stroustrup (AT&T)

Page 13: Object-Oriented Programming Languages (OOPLs) An Introduction

C++ features

Static typing by default No garbage collection Supports multiple inheritance Supports template classes

Page 14: Object-Oriented Programming Languages (OOPLs) An Introduction

C++

It is one of the most successful OO languages in commercial applicationsIs likely to remain very popular because achieves high performance characteristics - probably

the fastest of all oo languages possible to do anything at any level of the operating

system provides easy integration with other languages,

especially C good quality component libraries are available

Page 15: Object-Oriented Programming Languages (OOPLs) An Introduction

C++

“for applications that have a systems programming component, systems with demanding time or space requirements, and those that span several technical cultures or application areas. In such systems, more simple, less efficient and more specialized languages become liabilities”

B. Stroustrup

Page 16: Object-Oriented Programming Languages (OOPLs) An Introduction

C++- summary of features

Yes - templatesGenericity

NoObject Persistence

NoGarbage Collection

YesMultiple Inheritance

YesInheritance

PoorConcurrency

YesInformation Hiding

YesPolymorphism

Static(default)/DynamicTyping

Page 17: Object-Oriented Programming Languages (OOPLs) An Introduction

Eiffel

Many specialists regard as the best available oo language attempts to address issues of correctness, robustness, portability and

efficiency

Has several advantages over Java Eiffel introduced the concept of assertions Design and programming language Novel “melting ice” technology

Not widely adopted due to problems with the original compiler, but Chicago Board of Trade recently adopted it for its core trading systemAuthor: B. Meyer

Page 18: Object-Oriented Programming Languages (OOPLs) An Introduction

Eiffel - summary of features

Yes Genericity

Some supportObject Persistence

Optional and IncrementalGarbage Collection

YesMultiple Inheritance

YesInheritance

YesConcurrency

YesInformation Hiding

YesPolymorphism

StaticTyping

Page 19: Object-Oriented Programming Languages (OOPLs) An Introduction

Java

“Took the industry by storm” supports development of full fledged applications

and browser-run applets support for concurrency and security C++-like syntax, but no pointers, thus safer code supported by powerful vendor: SUN

Authors:J. Gosling, W. Joy, G. Steele(SUN)

Page 20: Object-Oriented Programming Languages (OOPLs) An Introduction

Java features

Portability - Java code compiles into platform independent byte-code which is interpreted on each platform by a java-virtual -machine.

code is completely portable, but at the cost of poor performance

Automatic garbage collectionMultiple inheritance supported only for interfaces.Rigorous support for exception (error) handlingSupports method execution across a network via Remote Method Invocation

Page 21: Object-Oriented Programming Languages (OOPLs) An Introduction

Java - feature summary

NoGenericity

Via JDBCObject Persistence

YesGarbage Collection

Only for interfacesMultiple Inheritance

Single for classesInheritance

ThreadsConcurrency

YesInformation Hiding

YesPolymorphism

StaticTyping

Page 22: Object-Oriented Programming Languages (OOPLs) An Introduction

Concluding remarks

C++ appeared until recently to be the most practical, successful, general purpose OOPL

Increasingly interest is turning to Java

OO Languages are powerful but still slightly immature

New languages are still emerging Need more class libraries