Foundations of Type Systems and Programming Language Classification
What Is a Type System?

A type system is a tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according to the kinds of values they compute.
— Benjamin C. Pierce, *Types and Programming Languages* (2002)
Before We Begin
Whenever people talk about programming languages, you'll often hear them bring up "Static Typing" and "Dynamic Typing."
Typing is generally one of the topics developers think about most when choosing a language.
Let's start with a brief look at what Static Typing and Dynamic Typing actually are.
Background Knowledge Worth Knowing Before We Dive In
Values and Types
A value is the concrete data a program computes (
32,"hello",true).A type is the name given to a set of those values, as well as the specification of the operations permitted on them (
int,string,bool).Without types, there is no basis for judging whether an operation like
32 + "hello"is meaningful.
Compile and Runtime
Source code → Compiler → Machine code / Bytecode → Execution
Compile time: the phase before execution, where code is translated. Structural rules are what can be checked at this stage.
Runtime: the phase where the program actually executes. Values are loaded into memory.
Which phase type checking happens in is the key fork in the road between static and dynamic typing.
Relationship with Interpreter Languages
CPython and CRuby compile source into bytecode before running it.
An interpreter is one way to execute code. Static and dynamic typing distinguish when its types are checked.
TypeScript checks types before execution. A JavaScript engine runs the resulting JavaScript.

(Illustration of Dynamic Typing and Static Typing by Kolja Wilcke https://x.com/01k)
A Summary of Basic Typing Concepts
A Typing System is the set of rules that defines how the types of variables, functions, and data are managed.
The main purposes of a Type System are as follows:
- Error prevention: proactively prevents the use of data with incorrect types.
- Code stability: makes program behavior more predictable.
- Optimization potential: allows compilers to optimize by leveraging type information.
In particular, the difference between Static Typing and Dynamic Typing comes down to when type checking occurs.
Static Typing
- Types are checked at Compile Time.
- The checker knows the types of variables and expressions before the program runs. It reads annotations where you write them and infers types elsewhere.
- Representative languages: C, C++, Java, C#, TypeScript, Kotlin
int age = "32"; // Compile error. Cannot assign a string to an integer variableAn advantage is that type errors are caught early, resulting in higher stability.
Some languages still ask you to specify parameter and return types at function boundaries before you write the body.
Dynamic Typing
- Types are checked at Runtime.
- In Python, values carry types. You can bind a name to an integer and later rebind it to a string.
- Representative languages: Python, JavaScript, Ruby, PHP
age = 32 # An integer value
age = "Thirty-two" # Rebind the same name to a stringAn advantage is flexible coding and faster development speed.
A disadvantage is that type errors can occur during execution, making debugging potentially difficult.
A static check can reject type errors before a program runs. A dynamic check uses the types of the actual values when an operation runs.
So where did all this begin?
First, we need to understand Lambda Calculus (λ-calculus).
Useful background knowledge before we continue
Variable: - a slot that holds a value (Parameter)
Abstraction: - function definition (Function Definition / Lambda Expression)
Application: - function call (Function Call)

There is a class of problems of elementary number theory which can be stated in the form that it is required to find an effectively calculable function *f* of *n* positive integers, such that *f*(x₁, x₂, ⋯, xₙ) = 2 is a necessary and sufficient condition for the truth of a certain proposition of elementary number theory involving x₁, x₂, ⋯, xₙ as free variables.
— Alonzo Church, *An Unsolvable Problem of Elementary Number Theory* (1936)
Lambda Calculus (λ-calculus)
Lambda Calculus (λ-calculus) is one of the foundational papers at the starting point of programming.
Church introduced lambda abstraction in a 1932 paper on logic. The 1936 paper above uses the calculus to ask which problems can be computed.
There, Church used Lambda Calculus to give a mathematically rigorous definition of the intuitive notion of Computability,
and it is recognized, alongside the Turing Machine, as one of the powerful and influential formal systems for defining computability.
The central result of this paper demonstrates that the Entscheidungsproblem, a difficult open problem in the mathematics of the time, is unsolvable.
The paper contains concepts foundational to functional programming, such as Anonymous Functions, Higher-Order Functions, and Function Application.
Lambda Calculus is quite difficult, but to summarize what many mathematicians and authors of computer science texts have said:
- Functions are treated as the most fundamental unit of computation.
- Turing Completeness is expressed using just three rules: variables, abstraction, and application.
Untyped lambda calculus checks no types on its terms, so any term can appear as a function argument.
That includes self-application, as in λx. x x.
With dynamic typing, operations inspect the types of their values at runtime. Python, for example, raises an error if you try to add a string and an integer.
The calculus put functions at the center of computation and became a foundation for later functional languages.
*Turing Completeness: a system with Turing Completeness can solve every computational problem that a Turing Machine can solve.
**Turing Machine: an abstract machine conceived by Alan Turing; computers follow this same structure. Lambda Calculus (λ-calculus)

A FORMULATION OF THE SIMPLE THEORY OF TYPES
(1940, Alonzo Church)
Four years later, Alonzo Church proposed a system that added "Types" to Lambda Calculus.
Through this work, the concept of a "Type System" that assigns input and output types to each variable and function made its first appearance,
and this research would become the skeleton of what we now call Static Typing.
So now we have seen the historical origins of both Static Typing and Dynamic Typing.
Let's now look at what a Lambda Calculus expression actually is.
But before that, let's use some middle-school mathematics to make it a little easier to grasp.
Understanding Lambda Expressions Through Middle-School Math
f(x) = x + 2 (a named function)Let's convert this into a lambda expression.
λx. x + 2 (an unnamed "anonymous" function)λx. x + 2 means "a function that takes x as input and adds 2 to it."
f(3) = 3 + 2 = 5
(λx. x + 2) 3 = 3 + 2 = 5 -- the result of applying it is the sameIn the math you learned in school, every function must be given a name like f or g, but in Lambda Calculus, a function itself is a value, so it can participate in computation without a name.
Think of it the way you first learned about substituting values for x and y back in middle school.
Similarities
Mathematical variables like x and y play the role of receiving input. The x in λx. x + 2 also acts like an input-receiving variable. In other words, when a value is given, it is substituted in and the function is evaluated.
Differences
x and y are simple variables, but lambda (λ) also serves the role of "defining a function."
λx. x + 2 itself can function as a single "Anonymous Function."
Sharp-eyed readers will have noticed that lambda (λ) is simply the notation for declaring x as an input variable, and λx means "from here on, I'll use as the input."
To be a bit more specific, λ is the symbol for expressing an 'Anonymous Function,'
and a lambda expression is simply a function that takes some value as input, performs a specific computation, and returns the result!
Use the playground to check an identity expression, a literal, or a two-operand calculation. Try λx: Nat. x + 2, then change Nat to Bool and check it again.
Now that we have a decent grasp of the basics, let's work through some actual Lambda Calculus.

Untyped Lambda Calculus (Untyped-λ-Calculus)
λx. x (identity function)
λx. λy. x + y (a function that adds two values)
→ Since there is no type system, any value can be passed, but type errors cannot be caught!
Here, x + y is pseudonotation used to aid understanding.
Pure Lambda Calculus has neither numbers nor addition operators.
In practice, even the number 2 is represented as a function of the form λf. λx. f (f x), which is known as Church Encoding.
Readers who plan to look up the original paper should keep this in mind.
Because there are no types, any value can be passed in, but by the same token, type errors cannot be caught in advance.
Typed Lambda Calculus (typed-λ-Calculus)
λn: Nat. n + 1 -- Takes a natural number and adds one
λb: Bool. if b then 1 else 0 -- Picks the natural number one or zero-> By specifying types on variables, if a value of the wrong type is passed in, the error can be detected before the computation even runs!
Actual Notation vs. Pseudonotation
-- Arithmetic notation for reading
λn: Nat. n + 1
-- STLC with primitive naturals and successor
λn: Nat. succ n
-- succ : Nat → Nat
-- Untyped Church encoding
zero = λf. λx. x
one = λf. λx. f x
succ = λn. λf. λx. f (n f x)
-- succ one →β* λf. λx. f (f x) (Church 2)
-- Adding types at one fixed type A
Num_A = (A → A) → A → A
succ_A = λn: Num_A. λf: A → A. λx: A. f (n f x)
-- succ_A : Num_A → Num_A-- Conditional notation for reading
λb: Bool. if b then 1 else 0
-- Untyped Church encoding
true = λt. λf. t
false = λt. λf. f
toNum = λb. b one zero
-- toNum true →β* one, toNum false →β* zero (with the names expanded)
-- Simply typed version at the Num_A type from above
Bool_Num_A = Num_A → Num_A → Num_A
true_A = λt: Num_A. λf: Num_A. t
false_A = λt: Num_A. λf: Num_A. f
one_A = λf: A → A. λx: A. f x
zero_A = λf: A → A. λx: A. x
toNum_A = λb: Bool_Num_A. b one_A zero_A
-- toNum_A : Bool_Num_A → Num_ALevel | Description |
|---|---|
Pseudonotation | Uses |
STLC + Primitive Functions | Declares primitive operations such as succ and zero with types and computation rules. |
Pure Church Encoding | Defines numbers, booleans, and operations as lambda terms. |
- Level
Pseudonotation
- Description
Uses
+,if, and numbers directly. For reader comprehension.
- Level
STLC + Primitive Functions
- Description
Declares primitive operations such as succ and zero with types and computation rules.
- Level
Pure Church Encoding
- Description
Defines numbers, booleans, and operations as lambda terms.
Church zero applies f zero times; succ adds one application. The conditional gives the boolean two numerals of the same type and lets it pick one. Church encoding examples

"You can learn Lisp in one day. But if you know Fortran, it will take three days." - Marvin Minsky
Put two early high-level languages side by side, FORTRAN and Lisp, and the difference in when they check types comes into view.
FORTRAN | 1957 | Static Typing | Type checking at compile time, fast execution speed |
- #1
FORTRAN
- #2
1957
- #3
Static Typing
- #4
Type checking at compile time, fast execution speed
Lisp | 1958 | Dynamic Typing | Type determined at runtime, flexible data structures |
- #1
Lisp
- #2
1958
- #3
Dynamic Typing
- #4
Type determined at runtime, flexible data structures
1) FORTRAN and static typing
IBM released FORTRAN in 1957. It was an early high-level language that gained wide use in scientific computing.
Characteristics
- Adopts a static type system.
- Performs type checking at compile time.
2) Lisp and dynamic typing
Implementation of John McCarthy's Lisp began in the fall of 1958. It was an early language for computation with functions and symbolic expressions.
Characteristics
- Adopts a dynamic type system.
- Performs type checking at runtime.
The history of programming languages is endless, so to put it simply:
Static Typing was implemented in FORTRAN as a compile-time type checking mechanism,
Lisp checked the types of values as operations ran.
As a side note, the type system introduced in FORTRAN was not a strict type system,
and strict static typing appeared in the ALGOL family of languages; the type system itself continued to evolve endlessly over the following decades.
Even so, the broad framework of Static Typing and Dynamic Typing remained intact.
After that, Static Typing and Dynamic Typing were further subdivided,
and subdivided again. Let's look at the different ways they can be categorized.

(Washington CSE583)
Classification by Type Inference
public class TypeInferenceExample1
{
public static void main(String[] args)
{
// Explicit type declaration (traditional approach)
int number = 10;
double pi = 3.14;
String message = "Hello, Type Inference!";
// Type inference (using the `var` keyword)
var inferredNumber = 20; // Inferred as `int`
var inferredPi = 3.14159; // Inferred as `double`
var inferredMessage = "Welcome to Java!"; // Inferred as `String`
System.out.println("Number: " + number + ", Inferred Number: " + inferredNumber);
System.out.println("Pi: " + pi + ", Inferred Pi: " + inferredPi);
System.out.println("Message: " + message + ", Inferred Message: " + inferredMessage);
}
}(The example shown is Java's var keyword as an illustration of type inference.)

Type Inference
Type inference is how a checker uses an expression and its context to work out a type you left unwritten.
Benjamin C. Pierce calls this type reconstruction in chapter 22 of Types and Programming Languages. Both terms are used for working out missing types.
A local variable in Java: with var count = 10, the initializer gives the variable type int.
A function under Hindley-Milner: λx. x returns its argument, so the input and output share the type variable α. The function has type α → α.
Both are inference. One fills in a local variable's type; the other works out a general type for a function.
The same language can ask you to write a type in one place and infer it in another.
Explicit annotation: the programmer supplies a type at that position, as in x: Int.
Type inference: the checker fills in an omitted type from the initializer or how the expression is used.
To understand this more deeply, let's also explain the Hindley-Milner Type System.

(Rules expressing the Hindley-Milner Type System)
The rules in Damas and Milner's 1982 paper describe which types a term can have in an environment. Read Γ ⊢ e : τ as: in environment Γ, term e has type τ.
Rule | Description | Relationship to the Hindley-Milner Type System |
|---|---|---|
[Var] Variable Rule | A variable | The basic rule for inferring the type of a variable. |
[App] Function Application Rule | If | Defines how types are inferred when a function is applied. |
[Abs] Lambda Abstraction Rule | If e has type τ′ in Γ extended with x : τ, then λx. e has type τ → τ′ in Γ. | Builds a function type from the parameter and body. |
[Let] Let-Binding Rule | If e₀ has type scheme σ in Γ and e₁ has type τ in Γ extended with x : σ, then let x = e₀ in e₁ has type τ. | Binds a name with let and types the body in that environment. |
[Inst] Instantiation Rule | If e has type scheme σ in Γ and σ′ is an instance of σ, then e also has type σ′ in Γ. | Specializes a polymorphic type at a use site. |
[Gen] Polymorphic Generalization Rule | When | Explains Let-Polymorphism in Hindley-Milner. |
- Rule
[Var] Variable Rule
- Description
A variable
xpresent in the environment (Γ) has typeσ.- Relationship to the Hindley-Milner Type System
The basic rule for inferring the type of a variable.
- Rule
[App] Function Application Rule
- Description
If
e0has typeτ → τ'ande1has typeτ, thene0 e1has typeτ'.- Relationship to the Hindley-Milner Type System
Defines how types are inferred when a function is applied.
- Rule
[Abs] Lambda Abstraction Rule
- Description
If e has type τ′ in Γ extended with x : τ, then λx. e has type τ → τ′ in Γ.
- Relationship to the Hindley-Milner Type System
Builds a function type from the parameter and body.
- Rule
[Let] Let-Binding Rule
- Description
If e₀ has type scheme σ in Γ and e₁ has type τ in Γ extended with x : σ, then let x = e₀ in e₁ has type τ.
- Relationship to the Hindley-Milner Type System
Binds a name with let and types the body in that environment.
- Rule
[Inst] Instantiation Rule
- Description
If e has type scheme σ in Γ and σ′ is an instance of σ, then e also has type σ′ in Γ.
- Relationship to the Hindley-Milner Type System
Specializes a polymorphic type at a use site.
- Rule
[Gen] Polymorphic Generalization Rule
- Description
When
ehas typeσ, ifαis not a free variable (free(Γ)), thenecan have type∀α.σ.- Relationship to the Hindley-Milner Type System
Explains Let-Polymorphism in Hindley-Milner.
For instance, [Inst] lets us use an identity function of type ∀α. α → α at Int → Int by substituting Int for α.

(Constraint-Based Typing)
A Constraint-Based Type System is an approach that collects constraints during the type inference process and then resolves them all at once.
In other words, it gathers all the required relationships (constraint conditions) and solves them to determine the final types.
Rather than matching types immediately at the point of function application, it first collects type constraints and resolves them later through Unification.
The language table keeps these choices separate from when a program's types are checked.
Strong Typing / Weak Typing
Static and dynamic typing distinguish when types are checked. The labels strong and weak are used for different questions: how readily values are converted, for example, or how easily code can get around a type check.
Start with conversions. JavaScript can concatenate a number and a string with + by converting the number to a string. Python raises TypeError for the same combination.
Soundness is a separate question. As the TypeScript handbook explains, features such as any and type assertions can leave some errors to surface at runtime.
Type System Classification by Language
The table lists where each language infers types and gives a concrete conversion or checking example, rather than ranking systems as strong or weak.
Language | Static / Dynamic | Conversion or check | Annotations and inference | Inference and HM | Notes |
|---|---|---|---|---|---|
C | Static | Integer promotions and arithmetic conversions | Explicit + inference (C23) | Language-specific rules | C23 lets auto infer a variable's type from its initializer. |
C++ | Static | Arithmetic conversions and explicit pointer casts | Explicit + inference | Language-specific rules | auto can deduce a variable type or the return type of some functions. |
Java | Static | Implicit widening from int to long | Explicit + inference | Language-specific rules | var gives a local variable its static type from the initializer. |
C# | Static | Implicit widening from int to long | Explicit + inference | Language-specific rules | The compiler infers a static type for var. Operations on dynamic values are bound at runtime. |
Go | Static | Explicit conversion between int and int64 | Explicit + inference | Language-specific rules | Function signatures specify parameter and result types. := works inside functions; var can infer types from initializers even at package scope. |
Rust | Static | Explicit conversions between integer types | Explicit + inference | Language-specific rules | Rust infers types for let bindings and closures. Named functions specify their parameter types and non-unit return types. |
Swift | Static | Implicit promotion from T to T? | Explicit + inference | Language-specific rules | Swift infers let and var types from initializers. A func declaration spells out parameter types and non-Void return types. |
Kotlin | Static | Assigning an Int value to a Long variable requires an explicit conversion such as toLong() | Explicit + inference | Language-specific rules | Kotlin infers val and var types and the return types of expression-bodied functions. Regular function declarations specify parameter types. |
Haskell | Static | fromIntegral converts an integral value to another numeric type | Inference by default; annotations allowed | HM family + type classes | Haskell infers types for top-level definitions. Type classes support overloaded operators. |
OCaml | Static | float_of_int converts an int to a float | Inference by default; annotations allowed | HM family + value restriction | OCaml infers types for let definitions. The value restriction controls which type variables it can generalize. |
TypeScript | Static | JavaScript coercions still apply at runtime | Explicit + inference | Language-specific rules | TypeScript uses structural checking and contextual inference. any and type assertions can relax static checks. |
Python | Dynamic | Mixed int and float arithmetic is supported | Optional type hints | Not applicable | Operations use the types of their values at runtime. Static analysis tools read type hints. |
JavaScript | Dynamic | '5' == 5 is true; '5' === 5 is false | No static type syntax | Not applicable | The two equality operators follow different rules for coercion. |
Ruby | Dynamic | "5" + 5 raises TypeError | No static type syntax | Not applicable | String concatenation does not automatically turn a number into a string. |
Common Lisp | Dynamic | Mixed integer and floating-point arithmetic is supported | Optional type declarations | Not applicable | Common Lisp is dynamically typed and lets you declare variable types with declare. |
- Language
C
- Static / Dynamic
Static
- Conversion or check
Integer promotions and arithmetic conversions
- Annotations and inference
Explicit + inference (C23)
- Inference and HM
Language-specific rules
- Notes
C23 lets auto infer a variable's type from its initializer.
- Language
C++
- Static / Dynamic
Static
- Conversion or check
Arithmetic conversions and explicit pointer casts
- Annotations and inference
Explicit + inference
- Inference and HM
Language-specific rules
- Notes
auto can deduce a variable type or the return type of some functions.
- Language
Java
- Static / Dynamic
Static
- Conversion or check
Implicit widening from int to long
- Annotations and inference
Explicit + inference
- Inference and HM
Language-specific rules
- Notes
var gives a local variable its static type from the initializer.
- Language
C#
- Static / Dynamic
Static
- Conversion or check
Implicit widening from int to long
- Annotations and inference
Explicit + inference
- Inference and HM
Language-specific rules
- Notes
The compiler infers a static type for var. Operations on dynamic values are bound at runtime.
- Language
Go
- Static / Dynamic
Static
- Conversion or check
Explicit conversion between int and int64
- Annotations and inference
Explicit + inference
- Inference and HM
Language-specific rules
- Notes
Function signatures specify parameter and result types. := works inside functions; var can infer types from initializers even at package scope.
- Language
Rust
- Static / Dynamic
Static
- Conversion or check
Explicit conversions between integer types
- Annotations and inference
Explicit + inference
- Inference and HM
Language-specific rules
- Notes
Rust infers types for let bindings and closures. Named functions specify their parameter types and non-unit return types.
- Language
Swift
- Static / Dynamic
Static
- Conversion or check
Implicit promotion from T to T?
- Annotations and inference
Explicit + inference
- Inference and HM
Language-specific rules
- Notes
Swift infers let and var types from initializers. A func declaration spells out parameter types and non-Void return types.
- Language
Kotlin
- Static / Dynamic
Static
- Conversion or check
Assigning an Int value to a Long variable requires an explicit conversion such as toLong()
- Annotations and inference
Explicit + inference
- Inference and HM
Language-specific rules
- Notes
Kotlin infers val and var types and the return types of expression-bodied functions. Regular function declarations specify parameter types.
- Language
Haskell
- Static / Dynamic
Static
- Conversion or check
fromIntegral converts an integral value to another numeric type
- Annotations and inference
Inference by default; annotations allowed
- Inference and HM
HM family + type classes
- Notes
Haskell infers types for top-level definitions. Type classes support overloaded operators.
- Language
OCaml
- Static / Dynamic
Static
- Conversion or check
float_of_int converts an int to a float
- Annotations and inference
Inference by default; annotations allowed
- Inference and HM
HM family + value restriction
- Notes
OCaml infers types for let definitions. The value restriction controls which type variables it can generalize.
- Language
TypeScript
- Static / Dynamic
Static
- Conversion or check
JavaScript coercions still apply at runtime
- Annotations and inference
Explicit + inference
- Inference and HM
Language-specific rules
- Notes
TypeScript uses structural checking and contextual inference. any and type assertions can relax static checks.
- Language
Python
- Static / Dynamic
Dynamic
- Conversion or check
Mixed int and float arithmetic is supported
- Annotations and inference
Optional type hints
- Inference and HM
Not applicable
- Notes
Operations use the types of their values at runtime. Static analysis tools read type hints.
- Language
JavaScript
- Static / Dynamic
Dynamic
- Conversion or check
'5' == 5 is true; '5' === 5 is false
- Annotations and inference
No static type syntax
- Inference and HM
Not applicable
- Notes
The two equality operators follow different rules for coercion.
- Language
Ruby
- Static / Dynamic
Dynamic
- Conversion or check
"5" + 5 raises TypeError
- Annotations and inference
No static type syntax
- Inference and HM
Not applicable
- Notes
String concatenation does not automatically turn a number into a string.
- Language
Common Lisp
- Static / Dynamic
Dynamic
- Conversion or check
Mixed integer and floating-point arithmetic is supported
- Annotations and inference
Optional type declarations
- Inference and HM
Not applicable
- Notes
Common Lisp is dynamically typed and lets you declare variable types with declare.
Language references: C23, Go, Rust, Swift, Kotlin, Haskell, OCaml.

A language that doesn't affect the way you think about programming, is not worth knowing.
— Alan J. Perlis
Closing Thoughts...
The type system of a programming language is not merely a technical tool; it is the crystallization of ideas and philosophy.
Beginning with Alonzo Church's Lambda Calculus and passing through the rivalry between FORTRAN and Lisp,
two poles emerged: Static Typing in pursuit of stability, and Dynamic Typing in pursuit of flexibility.
These two currents competed and converged over decades to form the foundation of modern languages, and they have since moved toward a new synthesizing philosophy known as gradual typing.
Before choosing a language, we actually tend to select it based on the libraries and frameworks most commonly used in the industry we want to enter.
But if you understand the type system, you can gain a deeper understanding of the libraries and frameworks that derive from a language's design intent,
and you will acquire the wisdom to choose the right tool (programming language) for the problem at hand.