Skip to main content
Definition Website Computer and Technology

Dynamic Type Checking

Subject: Computer and Technology noun /daɪˈnæm.ɪk ˈtaɪp ˌtʃɛk.ɪŋ/ 1 definition

  1. Definition (noun)

    Entry #258 · Updated

    Dynamic Type Checking is the process of verifying that values and operations have compatible types at runtime rather than during compilation. In this model, type information is attached to runtime values instead of statically bound to variables, allowing an interpreter or runtime environment to inspect types as expressions execute and raise an error if an incompatible operation is attempted. This boundary prioritizes flexibility and rapid iteration over compile-time guarantees, introducing runtime overhead and leaving unexecuted code paths unchecked until they run.

    Common Forms

    • Tagged-Value Checking: Runtime environments attach compact type tags or object headers to values in memory and verify them before executing primitive operations.

    • Duck Typing: Type compatibility is evaluated dynamically by checking whether an object provides the required methods or attributes at the moment an operation is called, rather than checking its declared class.

    • Runtime Casts and Downcasting: Statically typed languages insert dynamic checks when narrowing a general reference to a more specific subtype (such as Java type casts or C++ dynamic_cast), throwing an exception or returning null on a mismatch.

    • Gradual Typing Boundary Checks: Hybrid type systems enforce runtime guards or contracts where dynamically typed values enter statically typed modules so type soundness is preserved across the boundary.

    Example

    In a Python API endpoint, a billing function computes total = tax + price, assuming both fields parsed from an incoming JSON payload are numbers. The module loads cleanly without compile-time checks, and only when a request arrives with price encoded as the string "19.99" does the runtime inspect the operand types and raise a TypeError on the invalid + operation.