Advanced | Help | Encyclopedia
Directory


Strongly-typed programming language

(Redirected from Weakly-typed)

In computing, strongly-typed, when applied to a programming language, is used to describe how the language handles datatypes. "Strongly-typed" may have one of several incompatible meanings, depending on context. A programming language that is not strongly-typed is called weakly-typed. Some of the meanings that have been ascribed to "strongly-typed" include:

  1. A language is strongly typed if type annotations are associated with variable names, rather than with values. If types are attached to values, it is weakly typed.
  2. A language is strongly typed if it contains compile-time checks for type constraint violations. If all checking is deferred to run time, it is weakly typed.
  3. A language is strongly typed if it contains compile- or run-time checks for type constraint violations. If no checking is done, it is weakly typed.
  4. A language is strongly typed if conversions between different types are forbidden. If such conversions are allowed, it is weakly typed.
  5. A language is strongly typed if conversions between different types must be indicated explicitly. If implicit conversions are performed, it is weakly typed.
  6. A language is strongly typed if there is no language-level way to disable or evade the type system. If there are C-style casts or other type-evasive mechanisms, it is weakly typed.
  7. A language is strongly typed if it has a complex, fine-grained type system with compound types. If it has only a few types, or only scalar types, it is weakly typed.
  8. A language is strongly typed if the type of its data objects is fixed and does not vary over the lifetime of the object. If the type of a datum can change, the language is weakly typed. (This property is often, and less ambiguously, called "static typing.")
  9. A language is strongly typed if the type system provides strong guarantees about the run-time behaviour of the program before program execution. If the guarantees the type system provides are not strong, it's at most weakly typed.

Note that some of these definitions are contradictory, while others are merely orthogonal.

Because there is no generally-agreed meaning for the phrase "strongly-typed language," it is possible to find authoritative statements that many languages both are and are not strongly-typed. For example, under definitions 1, 7, and 8, the C language is strongly typed; under 4, 5, and 6 it is weakly typed — with definitions 2 and 3 open for further debate since C does perform type checks for compound types but not for scalar or array types. Accordingly, it is easy to find people who will claim that C is a "strongly-typed" language and others who will claim that it is a "weakly-typed" language.

Programming language expert Benjamin C. Pierce has said:

I spent a few weeks . . . trying to sort out the terminology of "strongly typed," "statically typed," "safe," etc., and found it amazingly difficult. . . . The usage of these terms is so various as to render them almost useless.

For a more thorough discussion of typing issues, see the article on datatypes and its related topics.








Links: Addme | Keyword Research | Paid Inclusion | Femail | Software | Completive Intelligence

Add URL | About Slider | FREE Slider Toolbar - Simply Amazing
Copyright © 2000-2008 Slider.com. All rights reserved.
Content is distributed under the GNU Free Documentation License.