Skip to content

type systems

Jorge Estanislao Barsoba edited this page Nov 26, 2021 · 1 revision

Must-Knows - Fundamentals - Type systems

  • Type-checking is answering a question about type equivalence, e.g. x = y, "Is the value that x holds equivalent to what y wants to hold?"
  • In Static languages (aka "strong-typed"), type-checking is performed at compile time; e.g. C#, TypeScript
  • In Dynamic languages (aka "weak-typed"), type-checking is performed at runtime; e.g. JavaScript
  • In *Nominal languages, *everything is about what is the name of your class; e.g. In Java, myCar is considered a Car only if its class is named Car
  • *Structural languages just care about shape; e.g. In TypeScript, myCar is considered a Car if it has the same properties than Car and its member's types can hold
  • Duck typing: When the language passes the "duck test", it's considered a duck-typed lang, like JavaScript; Duck-typed lang = Dynamic + Structural typed lang

    If it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck

Clone this wiki locally