One format choice

Why HCL?

A text format was needed that would be comfortable to edit by hand and strict enough to validate.

JSON was easy to validate but noisy to write. YAML was pleasant to write. HCL offered a useful feature: domain concepts could be blocks.

HCL was selected for the experiment.

{ "kind": "event", "name": "student_registered" } kind: event name: student_registered event "student_registered" { }

For this project, the block form is useful because the source resembles the concepts being discussed.

References and validation

event.school.student_registered

HCL parses this as a traversal expression. HCL does not know that it refers to an Event.

The .em.hcl validator supplies that meaning. It checks the reference kind, scope, and existence, then produces a typed model for the formatter, renderer, and other tools.

Tradeoffs

These formats solve different problems. This table describes the choices relevant to this project.

JSONYAML.em.hcl
Familiar ecosystemVery broadVery broadSmaller
Human editingVerboseCompactBlock-oriented
ReferencesUsually represented as dataUsually represented as dataHCL traversals plus .em.hcl validation
CommentsNo standard JSON commentsYesYes
StructureBrackets and bracesIndentationBlocks and braces
ValidationJSON Schema ecosystemSchema or tool dependentProject validator
Fit hereInterchangeLightweight authoringDomain-oriented authoring
CostMore syntax noiseSignificant whitespace and YAML semanticsCustom language tooling

Related work

YAML

EmLang

An Event Modeling language and toolchain using YAML. It includes editing, validation, and diagram tooling. If YAML is natural for your team, it is useful to look at.

EmLang on GitHub →

YAML

ESDM

Uses YAML manifests to model event-sourced domains and provides related validation, rendering, and editor tooling.

ESDM documentation →

JSON Schema

Martin Dilger's Event Modeling Specification

A JSON Schema representation of Event Models and an important input to this project.

Specification on GitHub →

Use the format that fits

HCL is not required for Event Modeling. It is the tradeoff this project explores.

If JSON or YAML fits your tooling better, use that.