Could Python supplant Java?

James J. Besemer jb at cascade-sys.com
Wed Aug 21 09:22:24 EDT 2002


> Rob Andrews <rob[nospam]@uselesspython.com> wrote in message news:<Xns92705C2BCBA0Erobuselesspythoncom at 24.28.95.158>...
> [snipped...]
> > *dynamic v. static* and *strong v. weak* are two distinct categories,
> > although the ability to point to a concise explanation is beyond me
> > presently.

The way I was taught the distinction was EARLY vs. LATE BINDING.

    http://www.cs.uh.edu/~marek/notes/lecture17a/tsld002.htm

That is, programming languages usually have the following elements:

    variables -- place holders for values, a way to assign mnemonic names

    values -- actual data of a particular type, operated upon by the program

    types -- constraining the ranges particular values can assume

Languages such as Pascal, C++ and Java have EARLY BINDING.

That is, variables have fixed types "bound" or associated with variables "early" on -- i.e., at compile time.
Variable-type associations cannot vary at runtime.  Only values can vary at runtime and then only within the constraints
defined by the associated variable's type.

Languages such as Lisp, Smalltalk and Python have LATE BINDING.

That is, variables are generic and may hold values of any type.  Types are firmly associated with the appropriate instances
at creation time.  Thus the association of type with variable/type may freely change at runtime but the association of type
with value is fixed throughout the value's lifetime.

                  compile time        runtime

Early binding:  ( variable, type ) <-> value

Late binding:    variable      <-> ( type, value )

Depending on language,

    variables are sometimes called slots

    types are sometimes called classes

    values are sometimes called objects or instances

Some languages, such as assembly language lie outside the mold as the notion of class/type is missing from the design.

Early and Late binding both may be fairly referred to as "strong" typing.  E.g., both types of languages may implement a
secure array type that, say, throws exceptions if subscripts are out of range rather than fail in some more obscure
fashion.

Some more zealous sources claim that "polymorphism" and other OOP techniques are impossible with early binding and thus
require late binding to make it possible.  This is bullshit.

However, saying both systems are "strong" suggests a near-equivlance when in fact the semantics and implications for
developers are rather different.

There are significant trade-offs to either approach.  People who think 'their' language is 'perfect' tend to believe the
approach used by their favorite language is 'best'.

Thus, true Pythonistas will argue that late binding (by any other name) is superior.

--jb

--
James J. Besemer  503-280-0838 voice
http://cascade-sys.com  503-280-0375 fax
mailto:jb at cascade-sys.com






More information about the Python-list mailing list