← Back to KaleidoScope

Published on November 28, 20263 min read

Static Types, Runtime Truth

What type systems can detect before execution, what remains a runtime question, and how developers can use both forms of feedback.

Static Types, Runtime Truth

A type checker can tell us that a value is expected to be a string, that a function returns a number, or that a particular operation is not valid for the declared types. This feedback can prevent entire classes of mistakes before a program runs. It is valuable—but it answers a narrower question than many developers assume.

Types describe constraints on values and operations. They do not automatically prove that a calculation is correct, that a user’s input matches the assumptions, or that a program handles every relevant state. A function can satisfy its type signature and still implement the wrong business rule. A list can contain integers and still contain the wrong integers.

What the checker can see

Static analysis examines a program without executing every possible path. Depending on the language and tool, it can detect incompatible operations, missing return paths, incorrect argument types, unreachable branches or suspicious use of values. The exact guarantees vary: some languages enforce types at compile time, while other tools infer or check annotations as an optional analysis layer.

Consider a function that receives a list of numbers and returns their average. A type declaration can express that the input is a list of numeric values and the result is a number. It does not, by itself, answer what should happen when the list is empty, whether non-finite values are allowed, or whether the caller is passing measurements in the correct units. Those are questions of specification and behaviour.

What execution reveals

Runtime tests exercise selected inputs and observe actual outcomes. They can reveal boundary errors, unexpected exceptions, incorrect calculations and interactions between components. But tests also have limits: they cover the cases someone thought to write, and their conclusions depend on whether the expected result is correct.

The two forms of feedback complement one another. A type checker can make assumptions explicit across a codebase. Tests can examine concrete behaviour. Code review can question whether the assumptions and expected outcomes make sense. None substitutes for the others.

Treat types as a map

It is useful to think of types as a map of intended relationships, not as a certificate that the territory is correct. A strong type system can make invalid states harder to represent, improve editor feedback and clarify interfaces. It cannot decide whether the model itself captures the real problem.

When a type check passes, the right conclusion is that the program satisfies the properties the checker knows how to verify. The next questions remain: are those properties sufficient, and does the program behave correctly under real conditions?

Discussion

Share your perspective.

0comments

There are no approved comments yet. Start the discussion.