Type safety β€” RexDac Academy

RexDac AcademyTechnical notes Β· Some prior knowledge helps
0%Published notes read Β· this device

Level 1 β€” The basics

Type safety

Original notes by SunDiaL Β· View English source

Type safety is a feature of the language that you program in. Such languages can also be referred to as:

  • Strongly typed (vs weakly typed)
  • Statically typed (if types are checked at compile time)
  • Hard typed / Soft typed (less common, informal terms)

These terms are often used interchangeably, but they don’t always mean exactly the same thing. For example, dynamic typing vs static typing refers to when the type is checked, not how strict the typing is.

A type safe language prevents you from mixing values of the wrong type. This helps catch mistakes early and improves reliability.

Examples:

Type safe β€” C#, Java, Rust

int x = "hello";  // compile-time error

Not type safe β€” JavaScript, Python

x = 5;
x = "now a string";  // allowed