# Static Typing

URL: https://softwaredictionary.org/terms/static-typing
Category: Programming Fundamentals
Last updated: 2026-10-03
In Turkish: Statik Tipleme
Pronunciation: STAT-ik TY-ping

In short: Static typing means the types of variables and expressions are checked before the program runs, usually by the compiler, so many type errors are caught early.

## What is static typing?

In a statically typed language such as Java, C#, Go, Rust, Kotlin or TypeScript, the compiler checks that values are used consistently with their types. Passing a string where a number is expected, calling a method that doesn't exist or forgetting to handle a possible null value can be reported as errors before the code ever runs.

Types don't always have to be written out. Type inference lets the compiler work them out, so `let count = 0` is known to be a number without a label. Explicit types are still common on function signatures, where they double as documentation: a reader can see what goes in and what comes out without reading the body.

The benefits grow with the size of the codebase. Editors can offer accurate autocompletion and safe automatic refactoring, such as renaming a method everywhere it is used, and a change that breaks a caller far away shows up immediately. The cost is more upfront ceremony and occasionally fighting the type checker when the types are hard to express.

A common misconception is that static typing means strong typing. They are separate ideas: static versus dynamic is about when types are checked, while strong versus weak is about how freely values are converted between types. C is statically but fairly weakly typed, and Python is dynamically but strongly typed.

## Key takeaways

- Types are checked before the program runs, usually at compile time.
- Java, C#, Go, Rust, Kotlin and TypeScript are statically typed.
- Type inference means many types don't have to be written by hand.
- It enables reliable autocompletion, refactoring and early error detection.
- Static versus dynamic is about when types are checked, not how strict they are.

## Example: A type error caught before running (TypeScript)

```typescript
function totalPrice(price: number, quantity: number): number {
  return price * quantity;
}

totalPrice(9.99, 3);      // fine

totalPrice("9.99", 3);
// Error: Argument of type 'string' is not assignable to parameter of type 'number'.
// Reported by the compiler and the editor; the code never runs with the bug.

let count = 0;            // inferred as number, no annotation needed
count = "zero";           // Error: Type 'string' is not assignable to type 'number'.
```

## Frequently asked questions

**Is TypeScript statically typed?**

Yes. TypeScript adds static types to JavaScript and checks them at compile time. The types are removed when it is compiled to JavaScript, so they don't exist at runtime.

**Does static typing prevent all bugs?**

No. It catches a class of mistakes, such as wrong types and missing fields, but not wrong logic. Tests are still needed to check that the code does the right thing.

**What is gradual typing?**

Adding optional types to a dynamically typed language, so a codebase can be typed bit by bit. TypeScript for JavaScript and type hints checked by tools like mypy for Python are examples.

---

Software Dictionary: https://softwaredictionary.org/ · https://softwaredictionary.org/llms.txt
