Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Comparison with Other Formats

This page compares WCL with JSON, YAML, TOML, and HCL across key features.

Feature Matrix

FeatureJSONYAMLTOMLHCLWCL
CommentsNoYesYesYesYes — line (//), block (/* */), doc (///); preserved by formatter
String interpolationNoNoNoYesYes — "host: ${host}:${port}"
Type systemImplicit (6 types)Implicit (dynamic)Explicit primitivesLimitedFull — primitives, composites, union, ref, any
SchemasExternal (JSON Schema)NoNoNoBuilt-in — first-class schema declarations with constraints
Variables / let bindingsNoAnchors onlyNoLimitedYes — let name = expr
ExpressionsNoNoNoLimited (templates)Yes — full arithmetic, logic, ternary, regex, lambdas
MacrosNoNoNoNoYes — function macros and attribute macros
ImportsNoNoNoHandled by TerraformYes — import "file.wcl" built-in
Query engineNo (external: jq)NoNoNoYes — built-in query(selector | filters)
TablesArrays of objectsSequencesArray of tablesNoYes — typed column declarations with row syntax
Control flowNoNoNofor_each (Terraform)Yes — for loops and if/else
Partial declarationsNoNoNoNoYes — partial blocks merged across files
DecoratorsNoNoNoNoYes — @decorator(args) with schemas
Validation blocksExternalNoNoNoBuilt-in — validation blocks with check and message
LSP supportVia pluginsVia pluginsVia pluginsVia pluginsYes — first-class wcl lsp with full feature set
FormattingExternal (prettier)ExternalExternalExternalYes — wcl fmt built-in
Bidirectional conversionPartialPartialNoYes — wcl convert to/from JSON/YAML/TOML

Comments

JSON has no comment syntax at all. Tools like jsonc or json5 add comments as extensions, but they are not part of the standard.

YAML supports # line comments.

TOML supports # line comments.

HCL supports //, #, and /* */ comments.

WCL supports three comment forms: // line comments, /* */ block comments (nestable), and /// doc comments which are attached to the following declaration. All comment forms are preserved by wcl fmt.

Schemas and Validation

JSON Schema is a separate specification applied externally. It is powerful but disconnected from the data file itself.

YAML, TOML, and HCL have no built-in schema mechanism.

WCL schemas are declared directly in WCL source and matched to blocks automatically by block type name. They support type constraints, required/optional fields, min/max, pattern matching, one_of, and cross-references between block types.

schema "ServiceSchema" {
  @required
  name : string
  @min(1) @max(65535)
  port : int
  host : string
}

service svc-api {
  name = "api"
  port = 8080
  host = "localhost"
}

Expressions and Variables

JSON and TOML are purely declarative — all values must be literals.

YAML supports anchors and aliases for value reuse, but no arithmetic or logic.

HCL (as used in Terraform) supports template expressions and some built-in functions.

WCL supports full expression evaluation: arithmetic, string interpolation, comparisons, logical operators, ternary expressions, list/map operations, regex matching, lambdas, and a built-in query engine.

Partial Declarations

WCL’s partial blocks are unique among configuration formats. A block can be declared in multiple files or multiple places in the same file with partial, and the pieces are merged before evaluation:

// base.wcl
partial service svc-api {
  host = "localhost"
}

// overrides.wcl
import "base.wcl"

partial service svc-api {
  port = 9090
}

// Result: service svc-api { host = "localhost", port = 9090 }

This enables layered configuration composition without inheritance hierarchies or external merge tools.

Decorators

WCL decorators attach metadata and behaviour to declarations. They are validated against decorator_schema definitions, making them typed and self-documenting:

decorator_schema "tag" {
  target = [block, attribute]
  env    : string
  tier   : string
}

@tag(env = "prod", tier = "critical")
service svc-payments {
  port = 8443
}

No other mainstream configuration format has an equivalent mechanism.

When to Use Each Format

FormatBest suited for
JSONMachine-generated config, REST APIs, interoperability
YAMLKubernetes manifests, CI pipelines, human-edited simple config
TOMLApplication config files (Cargo.toml, pyproject.toml)
HCLTerraform infrastructure definitions
WCLComplex configuration with shared logic, schemas, cross-file composition, and tooling