Skip to content

Serde Expressiveness

A breadth-first survey of the most expressive (de)serialization frameworks across languages — TypeScript, Rust, Python, Scala, Haskell, OCaml — to inform the redesign of sparkles:wired as a state-of-the-art serde framework in expressive power (it already competes on JSON performance), and to ground the plan of re-expressing CLI argument parsing as a bidirectional wired format (argv ⇄ struct).

This survey answers five questions:

  1. What can the strongest schema systems express — the full capability surface of Effect Schema, serde + its satellite ecosystem, Pydantic v2, and zio-schema, axis by axis? See the catalog and each deep-dive's analysis spine.
  2. What does bidirectionality actually require — how do one-declaration/ two-directions designs work (profunctor codecs, partial isomorphisms, flipped-AST interpretation in Effect), and which laws can honestly be promised? See concepts § round-trip laws.
  3. Where does each declaration style hit its ceiling — attributes/derives (serde, OCaml ppx, circe/aeson), value-level combinators (Haskell codecs), reified schemas (zio-schema, facet)? See concepts § the three tiers and comparison.
  4. Can argv be a serde format, bidirectionally — what did clap, serde_args, facet-args, and optparse-applicative prove about parsing, and why has nobody shipped the render half? See argv as a codec.
  5. What must sparkles:wired add — measured against a probe-verified baseline, which capabilities close the gap, which are novel-to-D, and which API decisions are not retrofittable? See the delta table.

Scope note. This is a survey of expressiveness, not performance — throughput comparisons appear only where they price a design choice (e.g. facet's reflection tax, tomland's interpretation-vs-codegen benchmark). The Effect Schema deep-dive was grounded in a local checkout of the v4 "smol" rewrite (pinned commit 3a1128c7); the wired baseline is grounded in runnable probes CI compiles and runs. The design decisions this survey feeds land in docs/specs/wired/ revisions, not here.

Last reviewed: August 9, 2026


Master Catalog

One row per surveyed subject. Tier is the three-tier classification by what artifact holds the structural knowledge (1 = codegen-only, 2 = value-level codec, 3 = reified schema). Declaration surface is what the user writes.

SubjectLanguage(s)TierDeclaration surfaceDistinguishing capabilityLink
Effect Schema (v4 "smol")TypeScript2/3value-level combinators over a reified ASTone parser run in two directions (flip); annotation-driven derivationseffect-schema.md
serde (+ serde_with, schemars)Rust1#[derive] + attributesthe universal-data-model architecture and its documented wallsserde.md
facetRust3one derive → runtime Shape valuereflection-as-data: one derive, N consumersfacet.md
Pydantic v2Python3class annotations compiled to a core schemawrap-hook middleware; presence provenance; callable discriminatorspydantic.md
msgspec & cattrsPython1/3annotated structs / converter objectsstrict schema-guided decode; policy-in-the-convertermsgspec-cattrs.md
zio-schemaScala3derived Schema[A] valuemigrations, diff/patch, DynamicValue — the full tier-3 payoffzio-schema.md
autodocodec, tomland & unjsonHaskell2hand-written profunctor codecsself-documenting codecs; path-anchored accumulation; updatehaskell-codecs.md
circe & aesonScala / Haskell1derived instances + optionsthe derivation-only ceiling, precisely mappedcirce-aeson.md
Invertible syntax descriptionstheory2partial-iso combinatorswhy codecs can't be monads; round-trip laws modulo equivalenceinvertible-syntax.md
OCaml ppx & ATDOCaml1/3[@@deriving] attributes / external .atdthe ?/~ field trichotomy; atddiff; a shipping D backendocaml-atd.md
argv as a codeccross-languageclap/optparse/facet-args/serde_argswhy parse-only is the universal state of the artargv-codecs.md
sparkles:wired (baseline)D1+structs + @Wire*!Format UDAsformat-generic CTFE policy table; probe-verified gapswired-baseline.md

The analysis spine

Every deep-dive analyses its subject through the same six dimensions, each closed with a D verdict carrying a feasibility tag:

  1. Schema model & bidirectionality — what artifact holds the structure; how the two directions derive from it; round-trip guarantees.
  2. Naming, optionality & defaults — renames, case conventions, aliases; the presence problem.
  3. Sum types & discriminationrepresentations, discriminators, ambiguity handling.
  4. Transformations & validation — converters/adapters, failure channels, refinements, cross-field rules.
  5. Errors & context — error structure, paths, accumulation; context threading through the codec.
  6. Metadata, derivations & extensibility — annotations beyond wire concerns; the artifacts one declaration yields; format genericity and unknown-field policy.

Taxonomy

By tier

TierSubjectsWhat the survey takes from them
1 — codegen-onlyserde, circe & aeson, OCaml ppx, wired todaythe attribute vocabulary; the precisely-mapped ceiling
2 — value-level codecHaskell codecs, invertible syntax, Effect Schemanon-drift by construction; docs/schema from the codec value
3 — reified schemazio-schema, facet, Pydantic, ATDN formats, migrations, diffing, generators from one artifact

By capability first proven there

CapabilityProven by
Docs/schema that cannot drift from the codecautodocodec
Migration algebra over a typed dynamic valuezio-schema
Inferred union sentinelsEffect Schema
Callable discriminatorsPydantic
Wrap-hook codec middlewarePydantic
Type-shaped adapter compositionserde_with
Presence provenance (exclude_unset)Pydantic
Path-anchored accumulation + usable partial valueunjson
update/PATCH merge semanticsunjson
Reflection artifact feeding N consumersfacet, zio-schema
Inspectable parser driving help/completionsoptparse-applicative

Milestones

WhenEvent
2008Boomerang (POPL '08): string lenses with static round-trip guarantees (invertible syntax)
2010Rendel & Ostermann, Invertible Syntax Descriptions — the parse/print duality theory
2017serde 1.0: the universal-data-model derive architecture stabilizes
2019tomland: the profunctor-codec pattern stated cleanly for TOML
2021autodocodec (self-documenting codecs) and zio-schema (reified Schema[A]) land the tier-2/3 answers
Jun 2023Pydantic v2: the schema layer reified and compiled to Rust (pydantic-core)
~2023ATD 2.13 ships atdd — a D backend for the schema-IDL-first approach
Feb 2025eserde: the Rust ecosystem retrofits error accumulation onto serde
2025facet: reflection-as-data lands in Rust — one derive, N consumers, at a measured runtime cost
2025–2026Effect Schema v4 "smol" rewrite: transformations/checks become first-class values; canonical codecs (surveyed at commit 3a1128c7)

Suggested reading paths

Sources

Each deep-dive carries its own primary-source block (official docs, pinned source links, issues, papers). Cross-cutting grounding:

  • The Effect Schema deep-dive reads the 7 272-line SCHEMA.md and the schema source of a local effect-smol checkout, pinned at commit 3a1128c7684e04d34d9f541f77adaac38a513056.
  • The wired baseline embeds runnable probes (compiled and run by ci --verify) for its load-bearing claims.
  • The survey's synthesis and delta live in comparison.md; shared vocabulary in concepts.md.