Strongly-typed programming language

Strongly-typed programming language

In computer science and computer programming, the term strong typing is used to describe those situations where programming languages specify one or more restrictions on how operations involving values having different data types can be intermixed. Its antonym is "weak typing". However, these terms have been given such a wide variety of meanings over the short history of computing that it is often difficult to know, out of context, what an individual writer means when using them.

Interpretation

Benjamin C. Pierce, author of "Types and Programming Languages" and "Advanced Types and Programming Languages", 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." [ [http://groups.google.com/group/comp.lang.perl.moderated/browse_frm/thread/e2e153d2ad7380c5/89b5f256ea7bfadb What "strongly typed" means] ]
Luca Cardelli's article Typeful Programming describes strong typing simply as the absence of unchecked runtime type errors. [ftp://gatekeeper.research.compaq.com/pub/DEC/SRC/research-reports/SRC-045.pdf page 3]

Most generally, "strong typing" implies that the programming language places severe restrictions on the intermixing that is permitted to occur, preventing the compiling or running of source code which uses data in what is considered to be an invalid way. For instance, an integer division operation may not be used upon strings; a procedure which operates upon linked lists may not be used upon numbers. However, the nature and strength of these restrictions is highly variable.

Meanings in computer literature

Some of the factors which writers have qualified as "strong typing" include:

*Static typing as opposed to dynamic typing. In a static type system, types are associated with variable names (usually when they are declared) rather than values (usually when they are created). The types may be inferred by the compiler and/or provided as annotations.
*The mandatory requirement, by a language definition, of compile-time checks for type constraint violations. That is, the compiler ensures that operations only occur on operand types that are valid for the operation.
*Type safety; that is, at compile or run time, the rejection of operations or function calls which attempt to disregard data types. In a more rigorous setting, type safety is proved about a formal language by proving progress and preservation.
*Disallowing type conversion. Values of one type cannot be converted to another type, explicitly or implicitly.
*Some authors reserve the phrase "strongly-typed language" for languages that omit implicit type conversion, that is, conversions that are inserted by the compiler on the programmer's behalf. For these authors, a programming language is strongly typed if types must be converted by an explicit notation, often called a "cast".
*The absence of ways to evade the type system. Such evasions are possible in languages that allow programmer access to the underlying representation of values, i.e., their bit-pattern.
*A complex, fine-grained type system with compound types.
*Fixed and invariable typing of data objects. The type of a given data object does not vary over that object's lifetime. For example, class instances may not have their class altered.
*Strong guarantees about the run-time behavior of a program before program execution, whether provided by static analysis or another mechanism.

Variation across programming languages

Note that some of these definitions are contradictory, while others are merely orthogonal. Because of the wide divergence among these definitions, it is possible to defend claims about most programming languages that they are either strongly- or weakly-typed. For instance:

*Java, Pascal and C require all variables to have a defined type and support the use of explicit casts of arithmetic values to other arithmetic types. Java and Pascal are often said to be more strongly typed than C, a claim that is probably based on the fact that C supports more kinds of implicit conversions than Pascal and C also allows pointer values to be explicitly cast while Java and Pascal do not. Java itself may be considered more strongly typed than Pascal as manners of evading the static type system in Java are controlled by the Java Virtual Machine's dynamic type system.
*OCaml and Haskell have purely static type systems, in which the compiler automatically infers a precise type for all values. Both languages are considered to have stronger type systems than Java, as they permit no implicit type conversions. While OCaml's libraries allow one form of evasion ("Object magic"), this feature remains unused in most applications.
*Common Lisp has a complex, fine-grained system of data types, but is almost entirely dynamically typed.
*Visual BASIC is a hybrid language. In addition to including statically typed variables, it includes a "Variant" data type that can store data of any type. Its implicit casts are fairly liberal where, for example, one can sum string variants and pass the result into an integer literal.
*Assembly language and Forth have been said to be "untyped". There is no type checking; it is up to the programmer to ensure that data given to functions is of the appropriate type. Any type conversion required is explicit.
* Ada is statically and strongly typed.

For this reason, writers who wish to write unambiguously about type systems often eschew the term "strong typing" in favor of specific expressions such as "static typing" or "type safety".

See also

*Data type includes a more thorough discussion of typing issues
*Comparison of programming languages has a table of languages showing whether or not they are strongly typed
*Type system
*Type safety

References


Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • Programming language — lists Alphabetical Categorical Chronological Generational A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that… …   Wikipedia

  • Mesa (programming language) — Mesa Appeared in 1970s and 80s Developer Xerox PARC Typing discipline strongly typed Influenced by ALGOL Influenced Java, Modula 2, Cedar Mesa was an innovat …   Wikipedia

  • Miranda (programming language) — Miranda Paradigm(s) lazy, functional, declarative Appeared in 1985 Designed by David Turner Developer …   Wikipedia

  • C Sharp (programming language) — The correct title of this article is C# (programming language). The substitution or omission of the # sign is because of technical restrictions. C# Paradigm(s) multi paradigm: structured, imperative …   Wikipedia

  • F Sharp (programming language) — The correct title of this article is F#. The substitution or omission of the # sign is because of technical restrictions. F# Paradigm(s) multi paradigm: functional, imperative, object oriented Appeared in 2002 (2002) …   Wikipedia

  • Oxygene (programming language) — Oxygene Developer RemObjects Software Stable release 3.0.21 (August 29, 2009; 2 years ago (2009 08 29)) Influenced by Object Pas …   Wikipedia

  • Python (programming language) — infobox programming language name = Python paradigm = multi paradigm: object oriented, imperative, functional year = 1991 designer = Guido van Rossum developer = Python Software Foundation latest release version = 2.6 latest release date =… …   Wikipedia

  • Ada (programming language) — For other uses of Ada or ADA, see Ada (disambiguation). Ada Paradigm(s) Multi paradigm Appeared in 1980 Designed by MIL STD 1815/Ada 83: Jean Ichbiah Ada 95: Tucker Taft Ada 2005: Tucker Taft Stable release …   Wikipedia

  • Criticism of the APL programming language — The APL programming language has been used since the mid 1960s on mainframe computers and has itself evolved in step with computers and the computing market. APL is not widely used, but minimalistic and high level by design, at several points in… …   Wikipedia

  • Curl (programming language) — Curl Paradigm(s) multi paradigm: object oriented, markup Appeared in 1998 Designed by Steve Ward, MIT Developer …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”