OOPLs - Computer Information Systems
Download
Report
Transcript OOPLs - Computer Information Systems
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
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
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
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.
Dynamic
Under 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.
Overview
Simula 67 – 1967
Smalltalk – 1970’s
C++ - 1986
Eiffel -1990
Java –1990’s
Simula 67
Introduced classes and hierarchical
inheritance for the first time
Motivated by a simulation application
Still has active users
Authors: Dahl and Nygaard
Simula 67 - Features
Typing
Polymorphism
Information Hiding
Concurrency
Inheritance
Multiple Inheritance
Garbage Collection
Object Persistence
Genericity
Hybrid (static/dynamic)
Yes
Yes
Yes
Yes
No
Yes
No
No
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
Smalltalk - summary of features
Typing
Polymorphism
Information Hiding
Concurrency
Inheritance
Multiple Inheritance
Garbage Collection
Object Persistence
Genericity
Dynamic
Yes
Yes
Poor
Yes
No
Yes
No
No
Smalltalk: pros and cons
Cons
Pros
Conceptually uniform
Great pedagogical tool:
Impossible to write
anything in a non-objectoriented style
Superb run-time
environment: debugging,
class browsing
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
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)
C++ features
Static typing by default
No garbage collection
Supports multiple inheritance
Supports template classes
C++
It is one of the most successful OO languages in
commercial applications
Is 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
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
C++- summary of features
Typing
Polymorphism
Information Hiding
Concurrency
Inheritance
Multiple Inheritance
Garbage Collection
Object Persistence
Genericity
Static(default)/Dynamic
Yes
Yes
Poor
Yes
Yes
No
No
Yes - templates
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 system
Author: B. Meyer
Eiffel - summary of features
Typing
Polymorphism
Information Hiding
Concurrency
Inheritance
Multiple Inheritance
Garbage Collection
Object Persistence
Genericity
Static
Yes
Yes
Yes
Yes
Yes
Optional and Incremental
Some support
Yes
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)
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 collection
Multiple inheritance supported only for interfaces.
Rigorous support for exception (error) handling
Supports method execution across a network via
Remote Method Invocation
Java - feature summary
Typing
Polymorphism
Information Hiding
Concurrency
Inheritance
Multiple Inheritance
Garbage Collection
Object Persistence
Genericity
Static
Yes
Yes
Threads
Single for classes
Only for interfaces
Yes
Via JDBC
No
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