lotus

previous page: 2.4) Is There A Difference Between Being A Member Or Instance Of A Class? (Typing - Object-Oriented Technology)
  
page up: Object-Oriented Technology FAQ
  
next page: 2.6) What Is This I Hear About ML And Functional Programming Languages? (Typing - Object-Oriented Technology)

2.5) What Is The Difference Between Static And Dynamic Typing? (Typing - Object-Oriented Technology)




Description

This article is from the Object-Oriented Technology FAQ, by Bob Hathaway rjh@geodesic.com with numerous contributions by others.

2.5) What Is The Difference Between Static And Dynamic Typing? (Typing - Object-Oriented Technology)

Static typing refers to types declared in a program at compile-time, so no type
information is available on objects at run-time. Dynamic typing uses the
inherent types of polymorphic objects, keeping track of the types of objects at
run-time. Statically typed dynamic binding is a compromise (usually
implemented with tables of function pointers and offsets), and is how
statically-typed OO languages provide polymorphism. Some approaches provide
both static and dynamic typing, sometimes with static typing providing type-
safe programs and dynamic typing providing multiple-polymorphism [Agrawal 91]
[Mugridge 91]. See also section 2.3.

Static typing is more efficient and reliable, but loses power. Typical
restrictions include only allowing a common set of base class functions (or
any common functions for the more general subtyping or parametric polymorphic
cases) to be available on formal objects and a lack of multiple-polymorphism
(see section 1.19), both of which are overcome with dynamic typing.

Many languages provide dynamic typing: Smalltalk, Self, Objective-C, and etc.
A limited dynamic typing scheme, called RTTI (Run Time Type Identification),
is even being considered for the C++ standard. A similar facility to safe
downcasting (historically known as type narrowing), the thrust of RTTI, can
also be found in recent versions of Eiffel.

See section 3.4 for a categorization of common OO languages by type system.

 

Continue to:













TOP
previous page: 2.4) Is There A Difference Between Being A Member Or Instance Of A Class? (Typing - Object-Oriented Technology)
  
page up: Object-Oriented Technology FAQ
  
next page: 2.6) What Is This I Hear About ML And Functional Programming Languages? (Typing - Object-Oriented Technology)