FACTOID # 110: Around 80% of all livejournal users are from the United States of America.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Dynamic typing

In computer science, a type system defines how a programming language classifies values and expressions into types, how it can manipulate those types and how they interact. A type indicates a set of values that have the same sort of generic meaning or intended purpose (although some types, such as abstract types and function types, might not be represented as values in the running computer program). Type systems vary significantly between languages with, perhaps, the most important variations being their compile-time syntactic and run-time operational implementations. Computer science, or computing science, is the study of the theoretical foundations of information and computation and their implementation and application in computer systems. ... A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. ... It has been suggested that value (programming) be merged into this article or section. ... An expression in a programming language is a combination of values and functions or procedures, interpreted according to the particular rules of precedence and of association for a particular programming language, which computes and then returns another value. ... A data type is a constraint placed upon the interpretation of data in a type system in computer programming. ...


A compiler may use the static type of a value to optimize the storage it needs and the choice of algorithms for operations on the value. For example, in many C compilers the "float" data type is represented in 32 bits, in accordance with the IEEE specification for single-precision floating point numbers. Thus, C uses floating-point-specific operations on those values (floating-point addition, multiplication, etc.). This article is about the computing term. ... C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ... A data type is a constraint placed upon the interpretation of data in a type system in computer programming. ... This article is about the unit of information. ... The IEEE Standard for Binary Floating-Point Arithmetic (IEEE 754) is the most widely-used standard for floating-point computation, and is followed by many CPU and FPU implementations. ...


The depth of type constraints and the manner of their evaluation affects the typing of the language. Further, a programming language may associate an operation with varying concrete algorithms on each type in the case of type polymorphism. Type theory studies type systems, although the concrete type systems of programming languages originate from practical issues of computer architecture, compiler implementation, and language design. In computer science, polymorphism means allowing a single definition to be used with different types of data (specifically, different classes of objects). ... At the broadest level, type theory is the branch of mathematics and logic that first creates a hierarchy of types, then assigns each mathematical (and possibly other) entity to a type. ...

Contents

Basis

Assigning data types (typing) gives meaning to collections of bits. Types usually have associations either with values in memory or with objects such as variables. Because any value simply consists of a set of bits in a computer, hardware makes no distinction even between memory addresses, instruction code, characters, integers and floating-point numbers. Types inform programs and programmers how they should treat those bits. This article is about the unit of information. ... The terms storage (U.K.) or memory (U.S.) refer to the parts of a digital computer that retain physical state (data) for some interval of time, possibly even after electrical power to the computer is turned off. ... In strictly mathematical branches of computer science the term object is used in a purely mathematical sense to refer to any thing. While this interpretation is useful in the discussion of abstract theory, it is not concrete enough to serve as a primitive datatype in the discussion of more concrete... In computer science and mathematics, a variable is a symbol denoting a quantity or symbolic representation. ... A BlueGene supercomputer cabinet. ... In computer science, a memory address is a unique identifier for a memory location at which a CPU or other device can store a piece of data for later retrieval. ... A computer can perform operations, each of which is assigned a numeric code called an opcode. ... The integers are commonly denoted by the above symbol. ... A floating-point number is a digital representation for a number in a certain subset of the rational numbers, and is often used to approximate an arbitrary real number on a computer. ...


Major functions that type systems provide include:

  • Safety - Use of types may allow a compiler to detect meaningless or probably invalid code. For example, we can identify an expression "Hello, World" + 3 as invalid because one cannot add (in the usual sense) a string literal to an integer. As discussed below, strong typing offers more safety, but it does not necessarily guarantee complete safety (see type-safety for more information).
  • Optimization - Static type-checking may provide useful information to a compiler. For example, if a type says a value must align at a multiple of 4, the compiler may be able to use more efficient machine instructions.
  • Documentation - In more expressive type systems, types can serve as a form of documentation, since they can illustrate the intent of the programmer. For instance, timestamps may be a subtype of integers—but if a programmer declares a function as returning a timestamp rather than merely an integer, this documents part of the meaning of the function.
  • Abstraction (or modularity) - Types allow programmers to think about programs at a higher level, not bothering with low-level implementation. For example, programmers can think of strings as values instead of as a mere array of bytes. Or types can allow programmers to express the interface between two subsystems. This localizes the definitions required for interoperability of the subsystems and prevents inconsistencies when those subsystems communicate.

A program typically associates each value with one particular type (although a type may have more than one subtype). Other entities, such as objects, modules, communication channels, dependencies, or even types themselves, can become associated with a type. For example: This article is about the computing term. ... A string literal is the representation of a string value within the source code of a computer program. ... The integers are commonly denoted by the above symbol. ... In computer science, type safety is a property attributed to some, but not all, programming languages. ... In general terms, documentation is any communicable material (such as text, video, audio, etc. ... An interface defines the communication boundary between two entities, such as a piece of software, a hardware device, or a user. ... In computer science, a subtype is a datatype that is generally related to another datatype (the supertype) by some notion of substitutability, meaning that computer programs written to operate on elements of the supertype can also operate on elements of the subtype. ... In strictly mathematical branches of computer science the term object is used in a purely mathematical sense to refer to any thing. While this interpretation is useful in the discussion of abstract theory, it is not concrete enough to serve as a primitive datatype in the discussion of more concrete... It has been suggested that this article or section be merged into Modularity (programming). ... In computer science, dependency or coupling is the degree to which each program module relies on each other module. ...

A type system, specified in each programming language, stipulates the ways typed programs may behave and makes behavior outside these rules illegal. An effect system typically provides more fine-grained control than a type system. A data type is a constraint placed upon the interpretation of data in a type system in computer programming. ... In object-oriented programming, classes are used to group related variables and functions. ... Kind can mean: Hundreds Bankekind Hundred - a hundred of Ostrogothia in Sweden Frökind Hundred - a hundred of Westrogothia in Sweden Hammarkind Hundred - a hundred of Ostrogothia in Sweden Hanekind Hundred - a hundred of Ostrogothia in Sweden Kind Hundred - a hundred divided between Hallandia, Smalandia and Westrogothia in Sweden Kinda... An effect system is a formal system which describes the computational effects of computer programs, such as side effects. ...


More formally, type theory studies type systems. At the broadest level, type theory is the branch of mathematics and logic that first creates a hierarchy of types, then assigns each mathematical (and possibly other) entity to a type. ...


Type checking

The process of verifying and enforcing the constraints of types – type checking – may occur either at compile-time (a static check) or run-time (a dynamic check). Static type-checking becomes a primary task of the semantic analysis carried out by a compiler. If a language enforces type rules strongly (that is, generally allowing only those automatic type conversions which do not lose information), one can refer to the process as strongly typed, if not, as weakly typed. In computer science, compile time, as opposed to runtime, is the time when a compiler compiles code written in a programming language into an executable form. ... In computer science, runtime describes the operation of a computer program, the duration of its execution, from beginning to termination (compare compile time). ... In computer science, semantic analysis is a pass by a compiler that adds semantical information to the parse tree and performs certain checks based on this information. ... This article is about the computing term. ...


Static and dynamic typing

A programming language is statically typed if type checking may be performed without testing equivalence of run-time expressions. A statically typed programming language respects the distinction between run-time and compile-time phases of processing. A language has a compile-time phase if separate modules of a program can be type checked separately (separate compilation), without information about all modules that exist at run time. A programming language is dynamically typed if the language supports run-time (dynamic) dispatch on tagged data. A programming language is dependently typed, if the phase distinction is violated and consequently the type checking requires testing equivalence of run-time expressions. [1]


In dynamic typing, type tag checking often takes place at runtime because values bound in variables can acquire different tags depending on the execution path. Type tags are represented using discriminated union types in statically typed programming languages. In computer science, run time (with a space, though often its spelled without one) describes the operation of a computer program, the duration of its execution, from beginning to termination (compare compile time). ... In set theory, a disjoint union or discriminated union is a set union in which each element of the resulting union is disjoint from each of the others; the intersection over a disjoint union is the empty set. ...


Dynamic typing often occurs in "scripting languages" and other rapid application development languages. Dynamic type tags appear more often in interpreted languages, whereas compiled languages favor static types without run-time tags. See typed and untyped languages for a fuller list of typed and untyped languages. Scripting languages (commonly called scripting programming languages or script languages) are computer programming languages that are typically interpreted and can be typed directly from a keyboard. ... // [edit] History Application Development refers to the developing of programming applications and differs from programming itself in that it has a higher level of responsibility, including for requirement capturing and testing. ... In computer programming, an interpreted language is a programming language whose programs may be executed from source form, by an interpreter. ... A compiled language is a programming language whose implementations are typically compilers (translators which generate machine code from source code), and not interpreters (step-by-step executors of source code, where no translation takes place). ... In computer science, some programming languages are typed and some are untyped. ...


The term duck typing refers to a form of dynamic typing implemented in languages which "guess" the type of a value. In computer science, duck typing is a form of dynamic typing in which a variables value itself implicitly determines what the variable can do. ...


To see how type tag checking works, consider the following pseudocode example: Pseudocode (derived from pseudo and code) is a compact and informal high-level description of a computer programming algorithm that uses the structural conventions of programming languages, but omits detailed subroutines, variable declarations or language-specific syntax. ...

 var x; // (1) x := 5; // (2) x := "hi"; // (3) 

In this example, (1) declares the name x; (2) associates the integer value 5 to the name x; and (3) associates the string value "hi" to the name x. In most statically typed systems, this code fragment would be illegal, because (2) and (3) bind x to values of inconsistent type. The integers are commonly denoted by the above symbol. ... In computer programming and some branches of mathematics, strings are sequences of various simple objects. ...


By contrast, a purely dynamically typed system would permit the above program to execute, since type tags are attached to values, not variables. The implementation of a dynamically typed language catches programmer errors related to the misuse of values—type errors—at the time of the computation of the erroneous statement or expression. In other words, dynamic typing catches errors during program execution. An expression in the very basic sense is the noun form of the verb express. ...


A typical implementation of dynamic typing keeps all program values "tagged" with a type tag, and checks the tag before using any value in an operation. For example:

 var x := 5; // (1) var y := "hi"; // (2) var z := x + y; // (3) 

In this code fragment, (1) binds the value 5 to x; (2) binds the value "hi" to y; and (3) attempts to add x to y. In a dynamically typed language, the value bound to x might be a pair (integer, 5), and the value bound to y might be a pair (string, "hi"). When the program attempts to execute line 3, the language implementation checks the type tags integer and string, and if the operation + (addition) is not defined over these two types it signals an error. In computer science, the term integer is used to refer to any data type which can represent some subset of the mathematical integers. ... In various branches of mathematics and computer science, strings are sequences of various simple objects (symbols, tokens, characters, etc. ...


Some statically typed languages have a "back door" in the language that enables programmers to write code that does not statically type check. For example, Java and C-style languages have "casting". This article needs cleanup. ...


The presence of static typing in a programming language does not necessarily imply the absence of dynamic typing mechanisms. For example, Java uses static typing, but certain operations require the support of runtime type tests, which are a form of dynamic typing. See programming language for more discussion of the interactions between static and dynamic typing. A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. ...


Static and dynamic type checking in practice

The choice between static and dynamic typing requires some trade-offs. A Tradeoff usually refers to losing one quality or aspect of something in return for gaining another quality or aspect. ...


Static typing finds type errors reliably at compile time. This should increase the reliability of the delivered program. However, programmers disagree over how commonly type errors occur, and thus what proportion of those bugs which are written would be caught by static typing. Static typing advocates believe programs are more reliable when they have been type-checked, while dynamic typing advocates point to distributed code that has proven reliable and to small bug databases. The value of static typing, then, presumably increases as the strength of the type system is increased. Advocates of strongly typed languages such as ML and Haskell have suggested that almost all bugs can be considered type errors, if the types used in a program are sufficiently well declared by the programmer or inferred by the compiler.[2] ML is a general-purpose functional programming language developed by Robin Milner and others in the late 1970s at the University of Edinburgh, whose syntax is inspired by ISWIM. Historically, ML stands for metalanguage as it was conceived to develop proof tactics in the LCF theorem prover (the language of... Haskell is a standardized pure functional programming language with non-strict semantics, named after the logician Haskell Curry. ...


Static typing usually results in compiled code that executes more quickly. When the compiler knows the exact data types that are in use, it can produce optimized machine code. Further, compilers in statically typed languages can find shortcuts more easily. Some dynamically-typed languages such as Common Lisp allow optional type declarations for optimization for this very reason. Static typing makes this pervasive. See optimization. Common Lisp, commonly abbreviated CL, is a dialect of the Lisp programming language, standardised by ANSI X3. ... It has been suggested that Loop optimization be merged into this article or section. ...


By contrast, dynamic typing may allow compilers and interpreters to run more quickly, since changes to source code in dynamically-typed languages may result in less checking to perform and less code to revisit. This too may reduce the edit-compile-test-debug cycle.


Statically-typed languages which lack type inference (such as Java) require that programmers declare the types they intend a method or function to use. This can serve as additional documentation for the program, which the compiler will not permit the programmer to ignore or drift out of synchronization. However, a language can be statically typed without requiring type declarations, so this is not a consequence of static typing.


Static typing allows construction of libraries which are less likely to be accidentally misused by their users. This can be used as an additional mechanism for communicating the intentions of the library developer.


Dynamic typing allows constructs that some static type systems would reject as illegal. For example, eval functions, which execute arbitrary data as code, become possible (however, the typing within that evaluated code might remain static). Furthermore, dynamic typing accommodates transitional code and prototyping, such as allowing a string to be used in place of a data structure. Recent enhancements (e.g. Haskell Generalized algebraic data types) to statically typed languages have allowed eval functions to be written in a type-safe way. In some programming languages, eval is a function which evaluates a string as though it were an expression and returns a result; in others, it executes multiple lines of code as though they had been included instead of the line including the eval. ... This article or section is in need of attention from an expert on the subject. ...


Dynamic typing typically makes metaprogramming more powerful and easier to use. For example, C++ templates are typically more cumbersome to write than the equivalent Ruby or Python code. More advanced run-time constructs such as metaclasses and introspection are often more difficult to use in statically-typed languages. Metaprogramming is the writing of programs that write or manipulate other programs (or themselves) as their data or that do part of the work that is otherwise done at runtime during compile time. ... C++ (pronounced see plus plus, IPA: ) is a general-purpose, high-level programming language with low-level facilities. ... Ruby is a reflective, object-oriented programming language. ... Python is a programming language created by Guido van Rossum in 1990. ... In object-oriented programming, a metaclass is a class whose instances are classes. ... In computing, type introspection is a capability of some object-oriented programming languages to determine the type of an object at runtime. ...


Strong and weak typing

Main article: strongly-typed programming language

One definition of strongly typed involves not allowing an operation to succeed on arguments which have the wrong type. A C cast gone wrong exemplifies the absence of strong typing; if a programmer casts a value in C, not only must the compiler allow the code, but the runtime should allow it as well. This allows compact and fast C code, but it can make debugging more difficult. The specification of nearly every high level computer programming language includes the concept of type. ... C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ... In computer science, type conversion or typecasting refers to changing an entity of one data type into another. ... Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic hardware thus making it behave as expected. ...


Some pundits use the term memory-safe language (or just safe language) to describe languages that do not allow undefined operations to occur. For example, a memory-safe language will also check array bounds. In computer programming, bounds checking is the name given to any method of detecting whether or not an index given lies within the limits of an array. ...


Weak typing means that a language implicitly converts (or casts) types when used. Revisiting the previous example:

 var x := 5; // (1) var y := "37"; // (2) x + y; // (3) 

Writing the code above in a weakly-typed language, it is not clear what kind of result one would get. Some languages such as Visual Basic, would produce runnable code which would yield the result 42: the system would convert the string "37" into the number 37 to make sense of the operation; other languages like JavaScript would produce the result "537": the system would convert the number 5 to the string "5" and then concatenate the two. In both Visual Basic and JavaScript, the resulting type is determined by rules that take both operands into consideration. In some languages, such as AppleScript, the resulting type of a value is determined by the type of the left-most operand only. Visual Basic (VB) is an event driven programming language and associated development environment from Microsoft for its COM programming model. ... JavaScript is the name of Netscape Communications Corporations and now the Mozilla Foundations implementation of the ECMAScript standard, a scripting language based on the concept of prototype-based programming. ... In mathematics, an operand is one of the inputs of an operator. ... AppleScript is a scripting language devised by Apple, Inc. ...


Careful language design has also allowed languages to appear weakly-typed (through type inference and other techniques) for usability while preserving the type checking and protection offered by strongly-typed languages. Examples include VB.Net, C# and Java. Type inference is a feature present in some strongly statically typed programming languages. ... Visual Basic . ... The title given to this article is incorrect due to technical limitations. ... Java is an object-oriented programming language developed by Sun Microsystems in the early 1990s. ...


Reduction of operator overloading, such as not using "+" for string concatenation in addition to arithmetic addition, can reduce some of the confusion caused by dynamic typing. Some languages use periods (.) or ampersands (&) for string concatenation, for example. In computer programming, operator overloading (less commonly known as operator ad-hoc polymorphism) is a specific case of polymorphism in which some or all of operators like +, = or == have different implementations depending on the types of their arguments. ...


Safely and unsafely typed systems

Main article: Type safety

A third way of categorizing the type system of a programming language uses the safety of typed operations and conversions. Computer scientists consider a language "type-safe" if it does not allow operations or conversions which lead to erroneous conditions. In computer science, a programming language is type safe when the language does not permit the programmer to treat a value as a type to which it does not belong. ...


Let us again have a look at the pseudocode example:

 var x := 5; // (1) var y := "37"; // (2) var z := x + y; // (3) 

In languages like Visual Basic variable z in the example acquires the value 42. While the programmer may or may not have intended this, the language defines the result specifically, and the program does not crash or assign an ill-defined value to z. In this respect, such languages are type-safe. Visual Basic (VB) is an event driven programming language and associated development environment, created by Microsoft. ...


Now let us look at the same example in C:

 int x = 5; char y[] = "37"; char* z = x + y; 

In this example z will point to a memory address five characters beyond y, equivalent to two characters after the terminating zero character of the string pointed to by y. The content of that location is undefined, and might lie outside addressable memory, and so dereferencing z at this point could cause termination of the program. We have a well-typed, but not memory-safe program — a condition that cannot occur in a type-safe language. This article discusses a general notion of reference in computing. ...


Polymorphism and types

The term "polymorphism" refers to the ability of code (in particular, functions or classes) to act on values of multiple types, or to the ability of different instances of the same data-structure to contain elements of different types. Type systems that allow polymorphism generally do so in order to improve the potential for code re-use: in a language with polymorphism, programmers need only implement a data structure such as a list or a dictionary once, rather than once for each type of element with which they plan to use it. For this reason computer scientists sometimes call the use of certain forms of polymorphism generic programming. The type-theoretic foundations of polymorphism are closely related to those of abstraction, modularity and (in some cases) subtyping. In computer science, polymorphism means allowing a single definition to be used with different types of data (specifically, different classes of objects). ... Generic programming is a style of computer programming where algorithms are written in an extended grammar and are made adaptable by specifying variable parts that are then somehow instantiated later by the compiler with respect to the base grammar. ... In computer science, abstraction is a mechanism and practice to reduce and factor out details so that one can focus on a few concepts at a time. ... It has been suggested that this article or section be merged into Modularity (programming). ... In computer science, a subtype is a datatype that is generally related to another datatype (the supertype) by some notion of substitutability, meaning that computer programs written to operate on elements of the supertype can also operate on elements of the subtype. ...


Duck typing

Main article: Duck typing

In some programming environments, two objects can have the same type even when they have nothing in common. One example is the C++ duality between an iterator and a pointer. Both provide an * operation, implemented by widely different mechanisms. In computer science, duck typing is a form of dynamic typing in which a variables value itself implicitly determines what the variable can do. ... C++ (pronounced see plus plus, IPA: ) is a general-purpose, high-level programming language with low-level facilities. ... In computer science, an iterator is an object which allows a programmer to traverse through all the elements of a collection, regardless of its specific implementation. ...


This technique is called "duck typing", based on the aphorism, "If it waddles like a duck, and quacks like a duck, it's a duck!"


Explicit or implicit declaration and inference

Many static type systems, such as C's and Java's, require type declarations: the programmer must explicitly associate each variable with a particular type. Others, such as Haskell's, perform type inference: the compiler draws conclusions about the types of variables based on how programmers use those variables. For example, given a function f(x,y) which adds x and y together, the compiler can infer that x and y must be numbers -- since addition is only defined for numbers. Therefore, any call to f elsewhere in the program that specifies a non-numeric type (such as a string or list) as an argument would signal an error. Type inference is a feature present in some strongly statically typed programming languages. ...


Numerical and string constants and expressions in code can and often do imply type in a particular context. For example, an expression 3.14 might imply a type of floating-point; while [1, 2, 3] might imply a list of integers; typically an array. This article or section is in need of attention from an expert on the subject. ... This article or section does not cite its references or sources. ...


Types of types

A type of types is a kind. Kinds appear explicitly in typeful programming, such as a type constructor in the Haskell programming language, which returns a simple type after being applied to enough simple types. For example, the type constructor Either has the kind * -> * -> * and its application Either String Integer is a simple type (kind *). However, in most programming languages type construction is implicit and hard coded in the grammar, there is no notion of kind as a first class entity. In computer science typeful programming is a programming style identified by widespread use of type information handled through mechanical typechecking techniques. ... Haskell is a standardized pure functional programming language with non-strict semantics, named after the logician Haskell Curry. ...


Types fall into several broad categories:

In computer science, primitive types — as distinct from composite types — are data types provided by a programming language as basic building blocks. ... The integers are commonly denoted by the above symbol. ... A floating-point number is a digital representation for a number in a certain subset of the rational numbers, and is often used to approximate an arbitrary real number on a computer. ... In computer science, a variable has integral type if the variable represents an integer. ... A floating-point number is a digital representation for a number in a certain subset of the rational numbers, and is often used to approximate an arbitrary real number on a computer. ... This article or section is in need of attention from an expert on the subject. ... In computer science, composite types are datatypes which can be constructed in a programming language out of that languages primitive types and other composite types. ... This article or section does not cite its references or sources. ... This article is about the data structure. ... In computing, an abstract data type (ADT) is a specification of a set of data and the set of operations that can be performed on the data. ... In computer science, a subtype is a datatype that is generally related to another datatype (the supertype) by some notion of substitutability, meaning that computer programs written to operate on elements of the supertype can also operate on elements of the subtype. ... A derived type is a type given a new type but structurally the same as the original type. ... In computer science, an object type (a. ... In computer science and mathematics, a variable is a symbol denoting a quantity or symbolic representation. ... In computing, a partial type is a data type definition which spans multiple source code files. ... In computer programming languages, a recursive type is a data type for values that may contain other values of the same type. ... A function object, often called a functor, is a computer programming construct allowing an object to be invoked or called as if it were an ordinary function, usually with the same syntax. ... In predicate logic, universal quantification is an attempt to formalize the notion that something (a logical predicate) is true for everything, or every relevant thing. ... In predicate logic, an existential quantification is the predication of a property or relation to at least one member of the domain. ... It has been suggested that this article or section be merged into Modularity (programming). ... In computer science and logic, a dependent type is a type which depends on a value. ...

Compatibility: equivalence and subtyping

A type-checker for a statically typed language must verify that the type of any expression is consistent with the type expected by the context in which that expression appears. For instance, in an assignment statement of the form x := e, the inferred type of the expression e must be consistent with the declared or inferred type of the variable x. This notion of consistency, called compatibility, is specific to each programming language. An expression in a programming language is a combination of values and functions or procedures, interpreted according to the particular rules of precedence and of association for a particular programming language, which computes and then returns another value. ... Assignment statement is a statement where a destination is assigned a specific value , mostly copied from a source , where the source can be either a variable , a constant or any other . ...


Clearly, if the type of e and the type of x are the same and assignment is allowed for that type, then this is a valid expression. In the simplest type systems, therefore, the question of whether two types are compatible reduces to that of whether they are equal (or equivalent). Different languages, however, have different criteria for when two type expressions are understood to denote the same type. These different equational theories of types vary widely, two extreme cases being structural type systems, in which any two types are equivalent that describe values with the same structure, and nominative type systems, in which no two syntactically distinct type expressions denote the same type (i.e., types must have the same "name" in order to be equal). A structual type system is a major class of type system, in which type compatibility and equivalence are determined by the types structure, and not through explicit declarations. ... A nominative type system is a major classes of type system, in which type compatibility and equivalence is determined by explicit declarations and/or the name of the types. ...


In languages with subtyping, the compatibility relation is more complex. In particular, if A is a subtype of B, then a value of type A can be used in a context where one of type B is expected, even if the reverse is not true. Like equivalence, the subtype relation is defined differently for each programming language, with many variations possible. The presence of parametric or ad hoc polymorphism in a language may also have implications for type compatibility. In computer science, a subtype is a datatype that is generally related to another datatype (the supertype) by some notion of substitutability, meaning that computer programs written to operate on elements of the supertype can also operate on elements of the subtype. ... In computer science, polymorphism means allowing a single definition to be used with different types of data (specifically, different classes of objects). ...


Controversy

There are often conflicts between those who prefer strong and/or statically-typed languages and those who prefer dynamic or free-form typing. The first group advocates for the early detection of errors during compilation and increased runtime performance, while the latter group advocates for rapid prototyping that is possible with a more dynamic typing system.[3] Related to this is the consideration that there's often no need to manually declare types in a programming language with type inference, thus the overhead is automatically lowered for some languages.


References

  1. ^ Harper, Robert & Benjamin C. Pierce (2005), "Design Considerations for ML-Style Module Systems", in Pierce, Benjamin C., Advanced Topics in Types and Programming Languages, Cambridge, MA: MIT Press, ISBN 0262162288
  2. ^ http://citeseer.ist.psu.edu/xi98dependent.html
  3. ^ Meijer, Erik and Peter Drayton. Static Typing Where Possible, Dynamic Typing When Needed: The End of the Cold War Between Programming Languages. Microsoft Corporation.

Microsoft is one of few companies engaging itself in the console wars Where they are up against sony, nintendo, and of course sharps new console which may cause a threat. ...

See also

Wikibooks
Wikibooks Ada Programming has a page on the topic of
Types
Wikibooks
Wikibooks Haskell has a page on the topic of


 
 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms, 1022, m