Skip to content
BENIBIX Learn

Statically Typed Language

Development🔤 LanguagesLanguage Kinds

Also known as Static Typing, Statically Typed

A language that checks the type of each value before it runs.

Think of it like

Think of it like jars with labels. The sugar jar only takes sugar, and you find out at once if you pour in salt.

Example

Jack says age is a number, then tries to store the text "thirty" in it. TypeScript stops him before the code ever runs.

Why it matters

Type checks catch a whole class of bugs early. They also help editors suggest the right names.

Definition

A statically typed language checks the type of every value before the program runs. Each variable has a fixed type, like number or text. If you put the wrong kind of value in, you get an error while building, not while the app is in use. Java, C, Rust, Go and TypeScript work this way. It takes a bit more typing, but many bugs never reach users.

Example code

typescript
let age: number = 30;
age = "thirty";
// error TS2322: Type 'string' is not assignable to type 'number'.
The mistake is caught while checking, before a single line runs.

Common mistake

Thinking static types mean no bugs. They catch wrong kinds of value, not wrong logic.

Key takeaways

  1. 1
    Checked first. Types are tested before the code runs.
  2. 2
    Fixed types. A number box stays a number box.
  3. 3
    Fewer surprises. Type slips never reach the user.

Compare

Learn it properly