{
  "schema_version": "1.0",
  "codex": "thecodex.expert/coding",
  "type": "concept",
  "slug": "how-languages-work/type-systems",
  "name": "Type Systems",
  "section": "How Languages Work",
  "canonical_definition": "A type system is a formal set of rules in a programming language that assigns a type to every expression and enforces constraints on how values of different types may be combined, with the purpose of preventing type errors — operations applied to values of incompatible types — either at compile time (static typing) or at runtime (dynamic typing).",
  "confidence": "high",
  "last_verified": "2026-06-01",
  "source_count": 5,
  "url": "https://thecodex.expert/coding/how-languages-work/type-systems/",
  "dimensions": {
    "static_dynamic": ["static (checked at compile time)", "dynamic (checked at runtime)"],
    "strong_weak": ["strong (no implicit coercion)", "weak (implicit coercion)"],
    "structural_nominal": ["structural (compatibility by shape)", "nominal (compatibility by name/declaration)"],
    "inference": ["manifest (explicit annotations required)", "inferred (compiler deduces types)"],
    "gradual": ["fully static", "gradual (mix of static and dynamic)", "fully dynamic"]
  },
  "by_language": {
    "C": {"static_dynamic": "static", "strong_weak": "weak"},
    "Java": {"static_dynamic": "static", "strong_weak": "strong"},
    "Rust": {"static_dynamic": "static", "strong_weak": "strong"},
    "Python": {"static_dynamic": "dynamic", "strong_weak": "strong"},
    "JavaScript": {"static_dynamic": "dynamic", "strong_weak": "weak"},
    "TypeScript": {"static_dynamic": "static (gradual)", "strong_weak": "strong"},
    "Go": {"static_dynamic": "static", "strong_weak": "strong"},
    "Haskell": {"static_dynamic": "static", "strong_weak": "strong", "inference": "Hindley-Milner"}
  },
  "concept_relationship": {
    "requires_first": ["foundations/binary-and-number-systems", "how-languages-work/compilation"],
    "enables": ["concepts/data-types", "concepts/variables", "languages/typescript", "languages/rust"],
    "commonly_confused_with": ["static/dynamic confused with strong/weak (independent dimensions)"]
  },
  "sources": [
    {"num": 1, "citation": "Pierce, B. C. (2002). Types and Programming Languages. MIT Press.", "tier": 1},
    {"num": 2, "citation": "Siek, J. G. & Taha, W. (2006). Gradual Typing for Functional Languages. Scheme and FP Workshop.", "tier": 1},
    {"num": 3, "citation": "Milner, R. (1978). A theory of type polymorphism in programming. JCSS 17(3), 348–375.", "tier": 1},
    {"num": 4, "citation": "Rossberg, A. et al. (2010). F-ing modules. TLDI '10. ACM.", "tier": 2},
    {"num": 5, "citation": "ECMAScript 2024 Language Specification (ECMA-262). Ecma International.", "tier": 1}
  ]
}
