Language engineering and Domain Specific Languages

Similar documents
Plan. Language engineering and Domain Specific Languages. Language designer defines syntax. How to define language

UML big picture. Perdita Stevens. School of Informatics University of Edinburgh

Model-Driven Engineering (MDE) Lecture 1: Metamodels and Xtext Regina Hebig, Thorsten Berger

Introduction to MDE and Model Transformation

Domain-Specific Languages Language Workbenches

Advanced Topics in Software Engineering (02265) Ekkart Kindler

Dániel Darvas Domain-specific languages (DSLs): what, how and when?

Introduction to Dependable Systems: Meta-modeling and modeldriven

Developing Web-Based Applications Using Model Driven Architecture and Domain Specific Languages

CISC836: Models in Software Development: Methods, Techniques and Tools

Variability differences among products in PL. Variability in PLE. Language Workbenches. Language Workbenches. Product Line Engineering

DSL Implementation. ... with language Workbenches. v1.1 Jan 16, Markus Voelter independent/itemis

Introduction to OpenArchitectureWare

Metamodeling. Janos Sztipanovits ISIS, Vanderbilt University

CSSE 490 Model-Based Software Engineering: Domain Specific Language Introduction

Static analysis and testing of executable DSL specification

Defining Domain-Specific Modeling Languages

Christian Doppler Laboratory

MDSE USE CASES. Chapter #3

A little History Domain Specific Languages Examples Tools Benefits A more theoretical View Programming and Modeling The LWES Project Bonus: Best

Language Extension and Composition with Language Workbenches

with openarchitectureware

Dominique Blouin Etienne Borde

Automatic Generation of Graph Models for Model Checking

challenges in domain-specific modeling raphaël mannadiar august 27, 2009

Software Architecture

Programming Modeling Two Worlds? Programmierung Modellierung Zwei Welten? und. and. Markus Voelter Independent/itemis

Grammars. Prof. Andreas Prinz. Introduction, Compilers. Examples Meta-models vs. Grammars Summary

Semantics of programming languages

Proceedings of the 6th Educators Symposium: Software Modeling in Education at MODELS 2010 (EduSymp 2010)

Compositional Model Based Software Development

Kermeta tutorial. How to create a metamodel. François Tanguy, Didier Vojtisek. Abstract

ABAP DSL Workbench SAP TechED 2016

Model Driven Engineering (MDE)

Metamodeling with Metamodels. Using. UML/MOF including OCL

Program generation for schema-based, typed data access

An Introduction to MDE

Syntax and Grammars 1 / 21

Practical DSL Design. Groovy Sydney Meetup May 4th, Peter Bell CEO/CTO SystemsForge

Semantics of programming languages

Model-based Software Engineering (02341, spring 2017) Ekkart Kindler

Domain Specific Languages. Requirements (Engineering)

Model-based Software Engineering (02341, spring 2016) Ekkart Kindler

PAPYRUS FUTURE. CEA Papyrus Team

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

BIG MODELS AN ALTERNATIVE APPROACH

ECLIPSE MODELING PROJECT

The Eclipse Modeling Framework and MDA Status and Opportunities

Automatized Generating of GUIs for Domain-Specific Languages

A conceptual framework for building good DSLs. Markus Voelter independent/itemis

Recent achievements in automated database design based on business process models

Second OMG Workshop on Web Services Modeling. Easy Development of Scalable Web Services Based on Model-Driven Process Management

Coral: A Metamodel Kernel for Transformation Engines

The UML Extension Mechanisms

Combined Object-Lambda Architectures

Software Engineering 2 A practical course in software engineering. Ekkart Kindler

Model-Level Integration of the OCL Standard Library Using a Pivot Model with Generics Support

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

Model-Independent Differences

Semantics of programming languages

Computation Independent Model (CIM): Platform Independent Model (PIM): Platform Specific Model (PSM): Implementation Specific Model (ISM):

Design Specification of Cyber-Physical Systems: Towards a Domain-Specific Modeling Language based on Simulink, Eclipse Modeling Framework, and Giotto

A few important patterns and their connections

Plan. A few important patterns and their connections. Singleton. Singleton: class diagram. Singleton Factory method Facade

What are Requirements?

This paper is more intended to set up a basis for a constructive discussion than to offer definitive answers and closed solutions.

Dominique Blouin Etienne Borde

Week - 01 Lecture - 04 Downloading and installing Python

Eclipse technology in IFMS Interface Management System

Whole Platform Foundation. The Long Way Toward Language Oriented Programming

Compilers and Code Optimization EDOARDO FUSELLA

A Comparison of Ecore and GOPPRR through an Information System Meta Modeling Approach


Model transformations. Model transformations. Model transformations. Model transformations

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

Modellierung operationaler Aspekte von Systemarchitekturen. Master Thesis presentation. October 2005 March Mirko Bleyh - Medieninformatik

Computer Organization & Assembly Language Programming

Preserving Non-essential Information Related to the Presentation of a Language Instance. Terje Gjøsæter and Andreas Prinz

Software Engineering 2 A practical course in software engineering. Ekkart Kindler

Defining Program Syntax. Chapter Two Modern Programming Languages, 2nd ed. 1

Types and Static Type Checking (Introducing Micro-Haskell)

Small is Beautiful Building a flexible software factory using small DSLs and Small Models

METADATA INTERCHANGE IN SERVICE BASED ARCHITECTURE

Model Driven Engineering (MDE) and Diagrammatic Predicate Logic (DPL)

Class diagrams and architectural design

Software Language Engineering of Architectural Viewpoints

openarchitectureware 4.1 An introduction

Types and Static Type Checking (Introducing Micro-Haskell)

A state-based 3-way batch merge algorithm for models serialized in XMI

Horváth Ákos Bergmann Gábor Dániel Varró István Ráth

DiverSE s Seminar about Software Language Engineering

Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m.

10 Thoughts 2 Demos * Discussions

Towards Generating Domain-Specific Model Editors with Complex Editing Commands

ATL: Atlas Transformation Language. ATL User Manual

MDSE PRINCIPLES. Chapter #2

Formal Specification of Software Systems

MDD with OMG Standards MOF, OCL, QVT & Graph Transformations

Matrex Table of Contents

Transcription:

Language engineering and Domain Specific Languages Perdita Stevens School of Informatics University of Edinburgh

Plan 1. Defining languages 2. General purpose languages vs domain specific languages 3. Internal and external DSLs 4. What about DSMLs? 5. Technologies Examples in the remaining labs: you must do the labs!

How to define language Recall: languages have syntax, semantics, pragmatics

Language designer defines syntax for modelling languages, split into: abstract (information needed to determine the semantics, e.g. what elements are there, how are they related) concrete (what the user actually says, e.g. specific keywords, shapes of graphic elements) answer questions like: what expressions are there in this language? is this expression legal in the language?

Language designer defines semantics; pragmatics emerge What does this legal expression mean? e.g., if I give you a model and a system, does the system conform to the model? Is this system one of the things the model could mean? Pragmatics are emergent: not defined by the language designer, but by users.

Hold on a moment! Why define languages? Why is there more than one programming language? (pause for discussion...)

Hold on a moment! Why define languages? Why is there more than one programming language? (pause for discussion...) If our domain is difficult to work with, given existing languages, what are our options?

Hold on a moment! Why define languages? Why is there more than one programming language? (pause for discussion...) If our domain is difficult to work with, given existing languages, what are our options? Are we talking about programming languages or modelling languages, textual or graphical? What s the difference?

Options for programming for a domain e.g., you re in overall charge of your organisation s software... You could

Options for programming for a domain e.g., you re in overall charge of your organisation s software... You could do nothing special: after all, your favourite language is Turing complete, it can do anything;

Options for programming for a domain e.g., you re in overall charge of your organisation s software... You could do nothing special: after all, your favourite language is Turing complete, it can do anything; write some classes and reuse them;

Options for programming for a domain e.g., you re in overall charge of your organisation s software... You could do nothing special: after all, your favourite language is Turing complete, it can do anything; write some classes and reuse them; develop a library;

Options for programming for a domain e.g., you re in overall charge of your organisation s software... You could do nothing special: after all, your favourite language is Turing complete, it can do anything; write some classes and reuse them; develop a library; develop a framework;

Options for programming for a domain e.g., you re in overall charge of your organisation s software... You could do nothing special: after all, your favourite language is Turing complete, it can do anything; write some classes and reuse them; develop a library; develop a framework; make your APIs provide a fluent interface;

Options for programming for a domain e.g., you re in overall charge of your organisation s software... You could do nothing special: after all, your favourite language is Turing complete, it can do anything; write some classes and reuse them; develop a library; develop a framework; make your APIs provide a fluent interface; develop a domain-specific language.

DSLs vs GPLs Quote and table from Markus Voelter, DSL Engineering, http://dslbook.org DSLs pick more characteristics from the third rather than the second column GPLs DSLs Domain large and complex smaller and well-defined Language size large small Turing completeness always often not User-defined abstractions sophisticated limited Execution via intermediate GPL native Lifespan years to decades months to years (driven by context) Designed by guru or committee a few engineers and domain experts User community large, anonymous and widespread small, accessible and local Evolution slow, often standardized fast-paced Deprecation/incompatible almost impossible feasible changes

DSL or GPL? Java

DSL or GPL? Java Haskell

DSL or GPL? Java Haskell UML

DSL or GPL? Java Haskell UML SQL

DSL or GPL? Java Haskell UML SQL HTML

DSL or GPL? Java Haskell UML SQL HTML Makefile

DSL or GPL? Java Haskell UML SQL HTML Makefile Use case diagrams

DSL or GPL? Java Haskell UML SQL HTML Makefile Use case diagrams scientific notation for numbers, e.g. 2.3 10 17

DSL or GPL? Java Haskell UML SQL HTML Makefile Use case diagrams scientific notation for numbers, e.g. 2.3 10 17

DSL or GPL? Java Haskell UML SQL HTML Makefile Use case diagrams scientific notation for numbers, e.g. 2.3 10 17 Like almost every interesting binary, it s actually more of a spectrum.

Internal vs external DSL Internal DSL: DSL text occurs within a program written in a host GPL parsed along with the GPL convenient for programmers who know the host GPL Example: SQL queries embedded in Java programs External DSL: DSL program is free-standing with its own parser etc. can suit non-programmers. Example: a makefile

Pros and cons of developing a DSL Pro: can get exactly the features you want can keep it simple otherwise so it can be made concise and usable Con: users won t know it already development work! especially, maintenance: of the language; of its tools; of the programs in it

How to make a DSL program do something? Two strategies: interpretation: there s an engine that can read the DSL program and do something as a result; code generation: there s a translation from the DSL program to something else (and an existing mechanism to make the something else do something).

Which comes first, abstract or concrete syntax? Abstract: get clean, consistent idea of the concepts to express, and then design the perfect concrete syntax for them or maybe more than one? Concrete: work out what you want to say using examples, then systematise and abstract. Recall the paleo example: we started with just one example in a concrete syntax, and worked out an abstract syntax.

And where does defining the semantics come in? In practice, you always know the semantics you re trying to express, as you define the syntax. At least roughly... Making that precise is then very hard... For programming languages: semantics is usually what the reference compiler/interpreter does. Can define formally operationally, denotationally, axiomatically... For modelling languages...? (Why the difference?)

Abstract syntax for graphical languages Key problem: not tree-like! Key solution: metamodelling

meta We usually say a metamodel is a model of the model but what we mean is more like a metamodel is a model that describes all the possible models Just think about class diagrams for a moment: model of a system describes how the objects can be configured: a running instance of the system conforms to the model, is an instance of the model; the system described by the model is approximately all the configurations the objects can be in, according to the model The model constrains those configurations: only some are legal. metamodel of a modelling language is what we get when we want the models to be the configurations. It tells us which models are legal. A model conforms to a metamodel. The metamodel is the model of the modelling language. metamodel defines abstract syntax

OMG 4-level metamodel hierarchy Picture from Brambilla et al., MDSE in Practice

In more detail: Picture from Brambilla et al., MDSE in Practice

Connecting to the Eclipse world OMG s hierarchy aims to be language-neutral. Eclipse tools implement it in Java, supporting facilities like generating Java code from a model, serialising it in XML, etc. EMF, the Eclipse Modeling Framework, supports those tasks. ecore is a metamodel, used within EMF, for defining models held in Eclipse. Corresponds to (part of) MOF in OMG terms.

Sketch of one way to define a DSML 1. abstract syntax: define metamodel using ecore 2. concrete syntax: define diagrammatic elements etc. e.g. using EMF/GMF tools or EuGENia 3. semantics: (e.g.) by generating Java code. To allow people to use it, generate a model editor in Eclipse (with validation etc.). Lab coming up.

Sketch of one way to define a textual DSL 1. concrete syntax: define a grammar using xtext 2. abstract syntax: generated from the grammar (can be expressed in ecore) 3. semantics: (e.g.) by generating Java code. To allow people to use your language, generate an editor in Eclipse (with validation etc.) Lab coming up.

Code generation using xtend xtend is essentially Java on steroids with awesome expressive notation that lets you express your logic in super elegant ways not possible in Java itself. Xtend compiles to Java source so anything that requires code written in Java can make use of code written in Xtend and Xtend can use anything written in Java so it s totally seamless. Ed Merks It s much easier to write code generation in xtend than in Java. We may see a little of this in the labs, but won t have time to go into much detail.

Why do we discuss DSLs and DSMLs together? You might think these were just two different choices: what are they doing in the same lecture? In practice the line between them is blurred by the very separation of concrete and abstract syntax we ve discussed. Abstract syntax: an abstract model, saying what s in your language. Concrete syntax: how the user sees it, could be graphical or textual, or something else. You saw in the OCL lab that there are several (many!) ecore editors, working with different presentations of an ecore model, and Eclipse happily switches between them: it s just concrete syntax...

What is a programming language anyway? Maybe it s a model... (Everything s a model!) Any sufficiently advanced technology is indistinguishable from magic. Arthur C. Clarke, Third Law.

Caution Arthur C. Clarke s second law also applies. The only way of discovering the limits of the possible is to venture a little way past them into the impossible.

Caution Arthur C. Clarke s second law also applies. The only way of discovering the limits of the possible is to venture a little way past them into the impossible. Currently, you can distinguish DSL engineering technology from magic by the flakiness of the tools. Will that ever go away? Well... maybe.*

Caution Arthur C. Clarke s second law also applies. The only way of discovering the limits of the possible is to venture a little way past them into the impossible. Currently, you can distinguish DSL engineering technology from magic by the flakiness of the tools. Will that ever go away? Well... maybe.* * I am neither elderly nor distinguished enough to fall into the trap of saying it s impossible. [Look up Clarke s first law.]

Conclusion We could very easily have an entire course on domain specific languages. Further reading (beyond what s required for this course!) Martin Fowler, Domain specific languages Ralf Lämmel, The Software Languages Book (to be published in 2017) Markus Voelter, DSL Engineering http://dslbook.org/ Lorenzo Bettini, Implementing Domain-Specific Languages with Xtext and Xtend Brambilla et al., MDSE in Practice https://www.sites.google.com/site/mdsebook/