Table Of ContentAntonio Bucchiarone
Antonio Cicchetti · Federico Ciccozzi
Alfonso Pierantonio Editors
Domain-Specific
Languages
in Practice
with JetBrains MPS
Domain-Specific Languages in Practice
Antonio Bucchiarone • Antonio Cicchetti •
Federico Ciccozzi • Alfonso Pierantonio
Editors
Domain-Specific Languages
in Practice
with JetBrains MPS
Editors
AntonioBucchiarone AntonioCicchetti
FondazioneBrunoKessler(FBK)-MoDiS SchoolofInnovation,Designand
Trento,Italy Engineering(IDT)
MälardalenUniversity
Västerås,Sweden
FedericoCiccozzi AlfonsoPierantonio
SchoolofInnovation,Designand UniversityofL’Aquila
Engineering(IDT) L’Aquila,Italy
MälardalenUniversity
Västerås,Sweden
ISBN978-3-030-73757-3 ISBN978-3-030-73758-0 (eBook)
https://doi.org/10.1007/978-3-030-73758-0
©TheEditor(s)(ifapplicable)andTheAuthor(s),underexclusivelicensetoSpringerNatureSwitzerland
AG2021
Thisworkissubjecttocopyright.AllrightsaresolelyandexclusivelylicensedbythePublisher,whether
thewhole orpart ofthematerial isconcerned, specifically therights oftranslation, reprinting, reuse
ofillustrations, recitation, broadcasting, reproductiononmicrofilmsorinanyotherphysicalway,and
transmissionorinformationstorageandretrieval,electronicadaptation,computersoftware,orbysimilar
ordissimilarmethodologynowknownorhereafterdeveloped.
Theuseofgeneraldescriptivenames,registerednames,trademarks,servicemarks,etc.inthispublication
doesnotimply,evenintheabsenceofaspecificstatement,thatsuchnamesareexemptfromtherelevant
protectivelawsandregulationsandthereforefreeforgeneraluse.
Thepublisher,theauthors,andtheeditorsaresafetoassumethattheadviceandinformationinthisbook
arebelievedtobetrueandaccurateatthedateofpublication.Neitherthepublishernortheauthorsor
theeditorsgiveawarranty,expressedorimplied,withrespecttothematerialcontainedhereinorforany
errorsoromissionsthatmayhavebeenmade.Thepublisherremainsneutralwithregardtojurisdictional
claimsinpublishedmapsandinstitutionalaffiliations.
ThisSpringerimprintispublishedbytheregisteredcompanySpringerNatureSwitzerlandAG.
Theregisteredcompanyaddressis:Gewerbestrasse11,6330Cham,Switzerland
Preface
ThefundamentalvisionproposedbyModel-DrivenEngineering(MDE)iscoping
with the complexity of reality by means of abstraction: The relevant aspects for
a certain application domain are described with models, which by definition are
simplifiedrepresentationsofasystemintherealworld[1].Inparticular,modelsare
abstractionsof real problemsand are defined using a set of well-definedconcepts
and their relationships, typically formalized in a modeling language definition.
Domain-SpecificLanguages(DSLs)havebeenintroducedwiththeaimofmeeting
the needs of particular application domains, industry, or business challenges,
which would be less efficiently addressed by using mainstream general-purpose
languages. In fact, DSLs are languages specifically defined to express problems
and/orsolutionsbyusingtermsappropriateforthespecificapplicationdomainand
hencefamiliartodomainexperts[2].
Language workbenches are tools with which DSLs can be designed, imple-
mented, tested, and in some cases used. In this respect, they play a critical role
for DSL development. A workbench should allow for a relatively easy language
specification while still providing language engineers with powerful editing and
automation features. Domain-specific concepts and their relationships should be
specifiedtogetherwithcorrespondingsemanticsandnotations,whiletheworkbench
is expected to offer generative mechanisms or interpreters deriving the necessary
programming environment, notably editors, palettes, auto-completion and valida-
tionfeatures,persistenceandversioning,andsoforth[3].Needlesstosay,additional
capabilitiesforsupportinglanguageextension,refinement,andmaintenanceareof
paramountrelevanceforthesuccessofindustry-strengthDSLstoo.
MPS, short for Meta Programming System, is an open source language
workbenchdevelopedby JetBrains overthe last 15 years. It is used to implement
languagesforreal-worlduse.Itsdistinguishingfeatureisprojectionalediting,which
supportsalmostunlimited languageextensionand compositionpossibilities [4]as
wellasaflexiblemixofawiderangeoftextual,tabular,mathematical,andgraphical
notations[5].
Thisbookisdesignedasanaccessiblemeanstointroducethereaderstoand/or
deepentheirexistingknowledgeofMPS.
v
vi Preface
The book begins with an overview of the domain of language workbenches,
which provides perspectives and motivations underpinning the creation of MPS.
Moreover, technical details of the language underneath MPS together with the
definitionofthetool’smainfeaturesarediscussedinchapter“JetBrainsMPS:Why
ModernLanguageWorkbenchesMatter”. Followingthis Introduction,the volume
isorganizedintothreeparts,eachdedicatedtoaspecificaspectofthetopic.
MPS inIndustrialApplications
Chapters “Use MPS to Unleash the Creativity of Domain Experts: Language
Engineering Is a Key Enabler for Bringing Innovation in Industry”, “JetBrains
MPS as Core DSL Technology for Developing Professional Digital Printers”,
“A Domain-Specific Language for Payroll Calculations: An Experience Report
from DATEV”, “FASTEN: An Extensible Platform to Experiment with Rigorous
Modeling of Safety-Critical Systems” and “Migrating Insurance Calculation Rule
DescriptionsfromWordtoMPS”presenttheuseofMPSinindustrialapplications.
Theycoverthe challengesandinadequaciesof general-purposelanguagesused in
companies,as opposedto the reasonswhy DSLs are essential, together with their
benefitsandefficiency;moreover,theysummarizelessonslearntbyusingMPS.
Chapter “Use MPS to Unleash the Creativity of Domain Experts: Language
Engineering Is a Key Enabler for Bringing Innovation in Industry” introduces
the experiences gained by utilizing MPS in smart factory, finance, and medical
domains.ThechapterdescribeshowappropriateDSLscouldbedefinedbymeans
ofMPStogetherwiththeireffectivenessinallowingexpertstoexploreandenhance
their domain-specific knowledge. Moreover,the chapter places MPS in a broader
perspective of core DSL engineering by discussing language adoption and the
most frequentlyused features. Chapter “JetBrains MPS as Core DSL Technology
for Developing Professional Digital Printers” reports on how the adoption of
MPS canlead to efficientand continuousinnovationwith sustainable quality.The
innovation is brought by means of new DSLs supporting feature management
and tool chaining for an industrial production application. Once a new DSL is
introduced in the industrial ecosystem, its functionality and suitability are tested
andevaluated.Chapter“ADomain-SpecificLanguageforPayrollCalculations:An
Experience Report from DATEV” reviews the developmentprocess of a DSL for
payrollcalculationsbymeansofMPS.Interestingly,theintroductionoftheDSLis
based on the demonstrated higher efficiency of using a DSL to deal with domain
complexitydriversincomparisontoageneral-purposelanguage.Theimplemented
DSL has reached an advanced maturity level and includes relevant features such
as versioning, re-use, and testing. Chapter “FASTEN: An Extensible Platform to
Experiment with Rigorous Modeling of Safety-Critical Systems” introduces an
open source research environment for model-based specification and design of
safety-criticalapplicationsanddescribesitscharacteristicsasacollectionofDSLs.
The chapter surveys the DSLs, and their development and utilization, and then
Preface vii
proposes a discussion of the lessons learnt by implementing them focusing on
the features of MPS that enabled that. Another industrial application is reported
in chapter “Migrating Insurance Calculation Rule Descriptions from Word to
MPS”, where existing C code plus natural language specifications in Word were
reverse-engineeredtowardaDSLunderadoptionintheassurancedomain.Indeed,
the underlying goal is to perform a structural cleanup and splitting into small
independentunitsoftheexistingroutines.Theincrementaladoptionprocessofthe
DSL is discussed together with a demonstrationof its effective results, especially
withrespecttoversioningandmemoryhandling.
MPS inResearch Projects
MPS implementations in research projects are discussed in chapters “Projecting
TextualLanguages”,“EngineeringGamefulApplicationswithMPS”,and“Learn-
ing Data Analysis with MetaR”: these projects cover the benefits of text-based
languages, the design and developmentof gamification applications, and research
fields with generally low expertise in language engineering. One of the strengths
of MPS, the provision of a mixture of different notations, is discussed in chapter
“ProjectingTextualLanguages”.In particular,thechapterpresentsan approachto
automaticallymapgrammar-basedlanguagedefinitionstowardcorrespondingDSLs
specified by MPS. Another research effort based on MPS features is presented
in chapter “Engineering Gameful Applications with MPS”, which illustrates the
creation of a gamification design framework as a collection of DSLs. Each DSL
addresses specific concerns of a gamification application design and deployment,
whiletheMPSlanguageworkbenchprovidesconsistencybyconstructionthrough
language extension mechanisms. Chapter “Learning Data Analysis with MetaR”
introducesa case study related to a tool designedto facilitate the use of DSLs by
researcherswithnontechnicalbackground.Inotherwords,aDSLcreatedbymeans
of MPS acts as a meta-toolto enhance the user-friendlinessof the base tool. Yet,
thanks to the features embedded in MPS, the tool includes language composition
for expert users, such that the meta-tool can be further extended and tailored to
specificneeds.
TeachingandLearning with MPS
Chapters“TeachingMPS:ExperiencesfromIndustryandAcademia”and“Teaching
LanguageEngineeringUsing MPS” present experienceson teaching and learning
with MPS. Chapter “Teaching MPS: Experiences from Industry and Academia”
focuses on teaching both industrial professionals and academic students. In par-
ticular, the chapter discusses the organizationof academic courses on MPS: first,
thebasicsoftext-basedlanguageworkbenchesareprovided,andthenthetechnical
viii Preface
details of MPS are presented. In this way, students can capture the distinctive
characteristics of MPS. Instead, chapter “Teaching Language Engineering Using
MPS” introduces the principles involved in DSL design and development in
conjunctionwith compiler theory,and then shows how MPS can be exploited for
thepracticalimplementationofthoseprinciples.
To summarize, this book covers several topics related to DSL engineering in
generalandhowtheycanbehandledbymeansoftheJetBrainsMPS.Thenumber
and diversity of the presented use-case demonstrate the strength and malleability
of the DSLs defined using MPS. The selected contributions, which represent the
currentstateoftheartandpracticeinusingJetBrainsMPStoimplementlanguages
forreal-worldapplications,areexpectedtobeofgreatinterestfortheModel-Driven
andSoftwareLanguagesEngineeringcommunities.
Perspectives
The insights brought by the book indicate that MDE’s state of the art and
practicedisplaythegrowingsuccessoflanguageworkbenchessupportingvarious,
sometimes blended [6], notations (Rascal [7], xText [8], and MPS, to mention a
few). Seamless blended notations can bring several benefits, among them flexible
separationofconcerns,multiviewmodelingbasedonmultiplenotations,convenient
text-based editing operations (inside and outside the modeling environment), and
eventuallyfaster modelingactivities [9]. In this respect, specifyingmodelsas text
may providegreatadvantagesvia the leverage of text manipulationtools, such as
text-based diff/merge, while leaving open the possibility of rendering portions of
modelsin a diagrammaticform(interestingly,the upcomingSysML v2[10]takes
thisdirectionbyprovidingatextualsyntax).
One of the reasonsforthe success oftext-basedlanguageworkbenchesistheir
pragmaticapproach:the simple definition of a (E)BNF grammar,i.e., the abstract
syntax, is usually enough to create the first prototype of a DSL, while concrete
syntaxescanbe incrementallyrefined.Thisisthe case forMPS, whichallowsthe
quickcreationoffullyfledgedtext-basedDSLswithlimitedeffort,bydefiningaset
of concepts, their properties, and relationships. Moreover, its projectional editing
conveysastructuredapproachtothecreation,visualization,andeditingofmodels.
Anopenissue,commontomostlanguageworkbenches,istheeffortrequiredfor
largecustomizations,includingtheirmaintenanceincaseoflanguageevolution.In
thisrespect,MPSprovidesthepossibilitytoalleviatemaintenanceissuesthrougha
powerfullanguageextensionmechanism.Indeed,severalchaptersinthebookrefer
to these mechanisms as one of the most relevant features of MPS. Moreover, the
movement toward web- and cloud-based solutions has affected the way language
workbenches are designed and evolved; this applies to MPS too, for which fully
fledgedweb-basedsolutions(e.g.,ModelixDSL1)areunderdevelopment.
1https://modelix.github.io/
Preface ix
Acknowledgments
The editors would like to express their deepest gratitude to all the authors who
havesubmittedtheirvaluablecontributionsandhaveprovidedtheirhighlyqualified
expertise in reviewing the chapters included in this book. Moreover, they would
like to thank RobertWalter—Senior Software DeveloperatUnity Technologies—
andFedericoTomassetti—SoftwareLanguageEngineeringexpertandCo-founder
atStrumenta—fortheirprofessionalsupportinreviewingsomeofthechapters.The
editorswouldalsoliketothanktheSpringerstafffortheircontinuoussupportand
dedication.In particular,the tireless supportfrom Ralf Gerstner,ExecutiveEditor
forComputerScienceatSpringer,hasbeengreatlyappreciated.
Trento,Italy AntonioBucchiarone
Västerås,Sweden AntonioCicchetti
Västerås,Sweden FedericoCiccozzi
L’Aquila,Italy AlfonsoPierantonio
References
1. Schmidt, D.C.: Guest Editor’sIntroduction:Model-drivenengineering.Com-
puter,39(2),25–31(2006).https://doi.org/10.1109/MC.2006.58
2. vanDeursen,A.,Klint,P.,Visser,J.:Domain-specificlanguages:anannotated
bibliography.SIGPLANNot.35(6),26–36.
https://doi.org/10.1145/352029.352035
3. Voelter,M.,Benz,S.,Dietrich,C.,Engelmann,B.,Helander,M.,Kats,L.C.L.,
Visser, E., Wachsmuth, G.: DSL engineering – designing, implementing and
using domain-specific languages, pp. 1–558. dslbook.org, ISBN 978-1-4812-
1858-0(2013)
4. Voelter, M.: Language and IDE modularization and composition with MPS.
In:GenerativeandtransformationaltechniquesinsoftwareengineeringIV,pp
383–430.Springer(2013)
5. Voelter, M., Lisson, S.: Supporting diverse notations in MPS’ projectional
editor.GEMOC@MoDELS2014,pp.7–16
6. Ciccozzi,F.,Tichy,M.,Vangheluwe,H.,Weyns,D.:Blendedmodelling-what,
why and how. In: 2019 ACM/IEEE 22nd InternationalConference on Model
Driven Engineering Languages and Systems Companion (MODELS-C), pp.
425–430.IEEE(2019)
7. Klint,P.,vanderStorm,T.,Vinju,J.J.:RASCAL:Adomainspecificlanguage
for source code analysis and manipulation. In: SCAM, pp. 168–177. IEEE
(2009)
8. Eysholdt, M., Behrens, H.: Xtext: Implement your language faster than the
quickanddirtyway.In:SPLASHCompanion,pp.307–309.ACM(2010)
x Preface
9. Addazi, L., Ciccozzi, F. (2021). Blended graphical and textual modelling for
UML profiles: a proof-of-concept implementation and experiment. J. Syst.
Softw.110912
10. ObjectManagementGroup.https://www.omgsysml.org/