Skip to content

static typing

Static typing is a form of type checking in which a program’s expressions and variables carry types that are verified before execution, usually at compile time.

A type system assigns a type to each expression and uses inference rules to decide whether a program is well typed. Code that fails the rules is rejected before running, so a successful check guarantees that certain classes of run-time error, such as calling a number as a function, can’t occur.

Programming languages apply static typing in different ways. C, C++, and early Java require explicit annotations on most declarations. Go and Rust strike a balance, requiring explicit annotations on function signatures while inferring the types of local variables.

Other languages like ML, Haskell, and OCaml apply Hindley-Milner type inference to deduce most types from how values are used. Python uses type hints, which are typically consumed by an external static type checker but don’t prevent or affect execution.

Static typing favors earlier error detection, safer large-scale refactoring, richer editor completions, and compiler optimizations.

Tutorial

Python Type Checking (Guide)

In this guide, you'll look at Python type checking. Traditionally, types have been handled by the Python interpreter in a flexible but implicit way. Recent versions of Python allow you to specify explicit type hints that can be used by different tools to help you develop your code more efficiently.

intermediate best-practices

For additional information on related topics, take a look at the following resources:


By Martin Breuss • Updated June 10, 2026 • Reviewed by Leodanis Pozo Ramos