Weak typing

Weak typing

In computer science, weak typing (a.k.a. "loose typing") is a property attributed to the type systems of some programming languages. It is the opposite of strong typing, and consequently the term "weak typing" has as many different meanings as strong typing does (see strong typing for a list and detailed discussion).

One of the more common definitions states that weakly-typed programming languages are those that support either implicit type conversion (nearly all languages support at least one implicit type conversion), ad-hoc polymorphism (also known as "overloading") or both. These less restrictive usage rules can give the impression that strict adherence to typing rules is less important than in strongly-typed languages and hence that the type system is "weaker". However, such languages usually have restrictions on what programmers can do with values of a given type; thus it is possible for a weakly-typed language to be type safe. Moreover, weakly-typed languages may be statically typed, in which case overloading is resolved statically and type conversion operations are inserted by the compiler, or dynamically typed, in which case everything is resolved at run time.

The advantage claimed of weak typing is that it requires less effort on the part of the programmer than strong typing, because the compiler or interpreter implicitly performs certain kinds of conversions. However, one claimed disadvantage is that weakly typed programming systems catch fewer errors at compile time and some of these might still remain after testing has been completed. Two commonly used languages that support many kinds of implicit conversion are C and C++, and it is sometimes claimed that these are weakly typed languages. However, others argue that these languages place enough restrictions on how operands of different types can be mixed, that the two should be regarded as strongly typed languages.

C++ places more restrictions on the handling of enumerated types than C:

enum animal {CAT=0,DOG=2,ANT=3}; animal a = CAT; /* The enum keyword here is optional in C++ */ animal b = 1; /* This is an error in C++ */


Wikimedia Foundation. 2010.

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

Look at other dictionaries:

  • Duck typing — Type systems Type safety Inferred vs. Manifest Dynamic vs. Static Strong vs. Weak Nominal vs. Structural Dependent typing Duck typing Latent typing Linear typing Uniqueness typing …   Wikipedia

  • strong typing — noun A system that places any of various kinds of restriction on the interactions between objects of different data types. Ant: loose typing, weak typing …   Wiktionary

  • Manifest typing — Type systems Type safety Inferred vs. Manifest Dynamic vs. Static Strong vs. Weak Nominal vs. Structural Dependent typing Duck typing Latent typing Linear typing Uniqueness typing …   Wikipedia

  • Type system — Type systems Type safety Inferred vs. Manifest Dynamic vs. Static Strong vs. Weak Nominal vs. Structural Dependent typing Duck typing Latent typing Linear typing Uniqueness typing …   Wikipedia

  • 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

  • Schwache Typisierung — Die Artikel Typsystem und Typisierung (Informatik) überschneiden sich thematisch. Hilf mit, die Artikel besser voneinander abzugrenzen oder zu vereinigen. Beteilige dich dazu an der Diskussion über diese Überschneidungen. Bitte entferne diesen… …   Deutsch Wikipedia

  • Typisierung (Informatik) — Eine Typisierung (engl. typing) dient in der Informatik dazu, dass die Objekte (hier Objekte im mathematisch abstrakten Sinne verstanden) der Programmiersprachen, wie z. B. Variablen, Funktionen oder Objekte (im Sinne der objektorientierten… …   Deutsch Wikipedia

  • Typkonzept — Die Artikel Typsystem und Typisierung (Informatik) überschneiden sich thematisch. Hilf mit, die Artikel besser voneinander abzugrenzen oder zu vereinigen. Beteilige dich dazu an der Diskussion über diese Überschneidungen. Bitte entferne diesen… …   Deutsch Wikipedia

  • C (programming language) — C The C Programming Language[1] (aka K R ) is the seminal book on C …   Wikipedia

  • DataReader — In ADO.NET, a DataReader is a broad category of objects used to sequentially read data from a data source. DataReaders provide a very efficient way to access data, and can be thought of as a Firehose cursor from ASP Classic, except that no server …   Wikipedia

Share the article and excerpts

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