This document contains an outline of a textbook on JetBrains Meta Programming System (JetBrains MPS) being written by Mikhail Barash. The purpose of this document is to have a discussion on the content structure of the textbook with MPS community members.
The textbook is meant for those without any prior experience on JetBrains MPS or language engineering. The author has some experience in teaching courses on MPS, and this book is planned as an embodiment of the methodological approaches used in different teaching settings.
The structural unit of the book is a double-page spread, rather than a page. Each spread is a finished piece of information — it has self-contained material on a particular topic. Some topics span over several spreads, and in such cases each of the spreads is devoted to a single subtopic.
The textbook is divided into three parts:
This choice and order of the parts is explained by a desire to avoid burdening the reader with language engineering terminology (from our experience, even "AST" scares off beginners.) We start with known terminology – classes, interfaces, enumerations – and slowly revise key notions and ideas using "appropriate" terminology. Moreover, the choice of the parts reflects typical patterns for building a software language.
Here are some of the highlights of the content of the textbook.
Editor
aspect tries to avoid making a big deal of projectional editing (see below). Actions
aspect in not mentioned until the second part of the book, where it comes naturally in one of the examples.Intentions
aspect and make a point about importance of domain-specific error support. We discuss an implementation of Invoice Calculator in Excel for comparison.TextGen
aspect, where we define a generator for Invoice Calculator
that generates RTF files.Generator
aspect: we define a generator for Invoice Calculator to XML. Generator
aspect and XSL transformations.Generator
. We deliberatly discuss Java code generation after RTF and XML to address a frequent opinion of the newcomers that MPS only allows generating Java code.Actions
aspect.Entities
language; we define code generators into Java, JavaScript/React and Excel/VBA. This selection of target languages is motivated by the need to communicate to the reader that MPS can be used to generate web applications as well as "legacy code".Generator
aspect, where we discuss in more details reductions, quotations, mapping labels, etc.Entities
language. By this time, the reader has implemented a tiny domain-specific language. Our goal here was to describe the development of a language from scratch within one "chapter". The second part is concluded by a discussion on evolution of Entities
language and language migration in MPS.baseLanguage
— we introduce several extensions of Java, talk again about Actions
, Constraints
, and Generator
aspects. We also discuss about extending Entities
language.PlainTextGen
.Below we list the spreads of the book.
Spread # | Topic | |
---|---|---|
0 | What is MPS? | |
1—2 | MPS as a Tool for Textual User Interfaces | |
3—6 | Object-Oriented Programming in MPS | |
7 | Intentions and Quickfixes | |
8—10 | Generating Text Output with TextGen |
|
11 | Generating XML Output with Generator |
|
12—13 | Generating Java Code with Generator |
|
14—16 | Projectional Editing: Pros and Cons | |
17—18 | Tabular and Graphical projections | |
19 | MPS as a Modelling Tool | |
20—21 | Looking at Code Through MPS Prism | |
22—24 | Entities Example |
|
25—26 | Scoping Rules and Constraints |
|
27—29 | Generating Java Code with Generator |
|
30—31 | Generating JavaScript Code | |
32 | Generating VBA Code | |
33—34 | Checking Domain Code: Type Systems | |
35 | Checking Domain Code: Data-Flow Analysis | |
36 | Evolution of Languages | |
37—39 | MPS as a Tool for Extending Existing Languages | Java/baseLanguage |
40 | MPS in Practice |
Rough estimate is Q2–Q3 2020.
It takes a significant amount of time not only to prepare the content of a spread, but also to layout it in a proper and engaging way. Inspired by this, this and this, we try to use encyclopedia-style layout (only layout — not content), for example, with boxes for extra material, and so on.
The book will be published electronically and will be open-source: all spreads will be published in Adobe Illustrator format (layers preserved etc.) so that they could be (re)used for creating teaching materials.