liveBook · Manning

Metamodel

As explained in Building User-Friendly DSLs

A metamodel is a model that precisely specifies the permitted structure, contents, properties, and types of models in a language.

A metamodel is a model that precisely specifies the permitted structure and contents of other models. For a DSL, it defines which concepts an AST can contain and which typed properties may accompany each concept. section 15.3

A useful shorthand is “metamodel = structure = concepts + properties + types.” Extracting one from structured data is metamodeling, which resembles data modeling. An explicit metamodel helps constrain DSL content, but should not prevent the language from evolving. section 15.3 section 15.5

Implementation choices affect how precisely the metamodel can be expressed:

  • JavaScript cannot make the implementation’s metamodel fully type-safe; TypeScript can partially define concept and property types, but constraints still require additional handling. section 15.3
  • Ecore provides a facility for describing metamodels within the Eclipse Modeling Framework, whose Core EMF supports in-memory model persistence and XML/XMI serialization. section 15.4.3
Figure 15.3 A version of figure 1.20 visualizing the notion of a metamodel describing the model, which is the DSL content
figure

Visualizes the metamodel as a model describing DSL content. section 15.3

Figure 15.4 A metamodel for DSL content representing a record type, borrowing the class diagram notation from UML
figure

Shows a record-type DSL metamodel using UML class-diagram notation. section 15.3

How Building User-Friendly DSLs covers it

How deep it goes
Explains concepts, properties, types, constraints, and implementation trade-offs, while deferring a fully type-safe JavaScript encoding.
Examples
Uses AST concept definitions, a record-type class diagram, and Ecore-based model persistence as concrete examples.
What it assumes
Assumes familiarity with DSLs, models, ASTs, and structured data while introducing the meaning and role of “meta.”
What you can do after
Evaluate DSL structure and choose between handwritten typing, TypeScript definitions, or metamodeling frameworks.
How it connects
Connects models, DSLs, ASTs, data modeling, TypeScript, Ecore, EMF, UML, and language workbenches.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building User-Friendly DSLs. The section links point to the parts of the book it draws on.