Encyclopedia > Dynamic typing

  Article Content

Dynamic typing

In programming languages, dynamic typing describes the practice of assigning types to each value in memory at runtime, rather than assigning a type to a static, syntactic entity in the program source code (the latter, contrasting practice is called static typing).

The implementation of a dynamically typed language will catch errors related to the misuse of values---"type errors"---at the time the erroneous statement or expression is computed. In other words, dynamic typing catches errors during program execution. A typical implementation of dynamic typing will keep all program values "tagged" with a type, and checking the type tag before any value is used in an operation.

For example, consider the following pseudocode:

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


Dynamic typing sometimes simplifies the task of writing code, because it allows the programmer to write code that would be illegal in some static type systems. Also, certain language constructs (for example, an eval function that can execute arbitrary data as code) are difficult to provide in a purely statically typed language.

However, purely dynamically typed languages provide only "late detection" of errors---errors may not be detected until the program is actually run. This complicates both the task of verifying that code is correct a priori, and the task of debugging code a posteriori when errors do arise. Dynamic typing advocates claim that the benefits of flexibility outweigh these disadvantages.

Well-known dynamically typed languages, in each of the major language paradigms, include the following:

Other dynamically typed languages include:

  • Ruby (a clean, pure-OO, interpreted language that gets out of the way and makes it easy to code in whatever style you deem appropriate.)
  • Python (a multi-paradigm language supporting all three styles)


  Search Encyclopedia

Search over one million articles, find something about almost anything!
  Featured Article
Christian Denominations

... Methodist Church[?] Church of the Nazarene Evangelical Church[?] Evangelical Methodist Church[?] Free Methodist Church[?] Fellowship of Independent Methodist ...