Seeing types where others don't

This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).

A developer documents their multi-year journey building a static type inference system for jq, the JSON processing tool. The post explains why jq's error messages are poor (no value provenance tracking), then walks through progressively more sophisticated approaches to inferring types from jq programs: starting with shape inference from field accesses, then adding type variables with constraint accumulation, and finally moving to a constraint-solver-based approach. Along the way, the author explores intersection types, overloaded operators, and the challenges of jq's stream semantics. The work-in-progress tool is called tjq and is available on GitHub. The broader takeaway is that even dynamically typed languages have implicit types, and we could leverage static inference to produce better error messages without requiring explicit annotations.

18m read timeFrom theconsensus.dev
Post cover image

Sort: