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

Similar documents
Language Workbenches, Embedded Software and Formal Verification

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

10 Thoughts 2 Demos * Discussions

Testing DSLs How to test DSLs, their IDEs and Programs

Domain Specific Languages. Product Line Engineering

Language Extension and Composition with Language Workbenches

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

What are Requirements?

Programming Languages

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

Domain Specific - a Binary Decision?

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

Compositional Model Based Software Development

Domain-Specific Languages Language Workbenches

Domain Specific Languages. Requirements (Engineering)

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

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

Language engineering and Domain Specific Languages

Object-oriented Compiler Construction

Let s build. like they build. Markus Völter Bernd Kolb

Introduction to Dependable Systems: Meta-modeling and modeldriven

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

Markus Völter

Declarative. Contracts

Coding and Unit Testing! The Coding Phase! Coding vs. Code! Coding! Overall Coding Language Trends!

Design Pattern and Software Architecture: IV. Design Pattern

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

Programming Assignment IV

Language Shapes (Architectural) Thought Markus Völter

Programming Assignment IV Due Monday, November 8 (with an automatic extension until Friday, November 12, noon)

Goals. Greater Geate Abstraction work on a higher level do more with less insulate from technology. Increase Value. Reduce lossiness.

DESIGN, EVOLUTION AND USE

Design Patterns. An introduction

REVIEW AND OUTLOOKS OF THE MEANS FOR VISUALIZATION OF SYNTAX SEMANTICS AND SOURCE CODE. PROCEDURAL AND OBJECT ORIENTED PARADIGM DIFFERENCES

Contemporary Design. Traditional Hardware Design. Traditional Hardware Design. HDL Based Hardware Design User Inputs. Requirements.

CSSE 490 Model-Based Software Engineering: Software Factories

Topic 1: Introduction

ArchiMate 2.0. Structural Concepts Behavioral Concepts Informational Concepts. Business. Application. Technology

Semantic Modularization Techniques in Practice: A TAPL case study

Describing the architecture: Creating and Using Architectural Description Languages (ADLs): What are the attributes and R-forms?

The PISA Project A Model Driven Development case study

Projecting a Modular Future

Lectures 20, 21: Axiomatic Semantics

Automated Testing of DSL Implementations

Verification and Validation. Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 1

CMPT Data and Program Organization

Concepts of Programming Languages

Design Pattern: Composite

Topics in Object-Oriented Design Patterns

Frustrated by all the hype?

Introduction to MDE and Model Transformation

Modelica Change Proposal MCP-0019 Flattening (In Development) Proposed Changes to the Modelica Language Specification Version 3.

Programming Languages (PL)

Principles of Programming Languages

Programming Languages 2nd edition Tucker and Noonan"

extensible Markup Language

Comp 411 Principles of Programming Languages Lecture 7 Meta-interpreters. Corky Cartwright January 26, 2018

Applying Model Driven Technologies in the Creation. of Domain Specific Modeling Languages

An Information Model for High-Integrity Real Time Systems

MDSE USE CASES. Chapter #3

What do Compilers Produce?

G Programming Languages Spring 2010 Lecture 4. Robert Grimm, New York University

CSc 372. Comparative Programming Languages. 2 : Functional Programming. Department of Computer Science University of Arizona

Part 5. Verification and Validation

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

Inheritance (Chapter 7)

AADL Graphical Editor Design

Principles of Programming Languages

A Multi-layered Domain-specific Language for Stencil Computations

Distributed Systems Programming (F21DS1) Formal Verification

Lecture 13: Expression Evaluation

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

Runtime Checking for Program Verification Systems

G Programming Languages - Fall 2012

Compilers and Interpreters

Architecture-driven development of Climate Control Software LMS Imagine.Lab Embedded Software Designer Siemens DF PL

a paradigm for the Introduction to Semantic Web Semantic Web Angelica Lo Duca IIT-CNR Linked Open Data:

Domain-Specific Languages for Composable Editor Plugins

Reading assignment: Reviews and Inspections

Definition of Information Systems

Verification and Validation. Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 1

Semester (kick-off) project: The BRAINF CK Language

Feature Modeling. Krzysztof Czarnecki & Simon Helsen University of Waterloo

with openarchitectureware

Page 1. Reading assignment: Reviews and Inspections. Foundations for SE Analysis. Ideally want general models. Formal models

Verification and Validation

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern

The etrice Eclipse Project Proposal

Types II. Hwansoo Han

Metamodeling. Janos Sztipanovits ISIS, Vanderbilt University

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Compiler Design

CSE 12 Abstract Syntax Trees

SDC Design patterns GoF

Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming

CS558 Programming Languages

Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1

Static Analysis by A. I. of Embedded Critical Software

CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009

An Introduction to Software Engineering. David Greenstein Monta Vista High School

Visitor Pattern.» Represent an operation to be performed on all of the components of an object structure

Transcription:

DSL Design A conceptual framework for building good DSLs Markus Voelter independent/itemis voelter@acm.org www.voelter.de voelterblog.blogspot.de @markusvoelter +Markus Voelter based on material from a paper written with Eelco Visser E.Visser@tudelft.nl http://eelcovisser.org/

This material is part of my upcoming (Feb. 2013) book DSL Engineering Designing, Implementing and Using Domain-Specific Laguages Stay in touch; it will be cheap :-) http://dslbook.org

Introduction

A DSL is a focussed, processable language for describing a specific concern when building a system in a specific domain. The abstractions and notations used are natural/suitable for the stakeholders who specify that particular concern.

General Purpose C Components State Machines Domain Specific Sensor Access LEGO Robot Control

Modular Language my L a b c d e f g h i j k l with many optional, composable modules

Case Studies

Example Compo nents

Example Compo nents

Example Refrigerators Refrige rators

Example Refrige rators

Example Refrige rators

Example Exten ded C

Example Pension Plans

Example Pension Plans

Example Web DSL

Terms & Concepts

Domain

deductive top down body of knowledge in the real world Domain Example Example Refrigerators Penion Plans Refrige rators

Domain Domain existing software inductive bottom up Example Example (family) Exten ded C Compo netns

Programs are trees element

Programs are graphs, really. reference

Fragments are subtrees w/ root fragment root fragment f

Languages are sets of concepts C 1 C 2 C 3 C n L

Languages are sets of concepts C 1 C 2 C 3 C n L

Programs and languages C 1 C 2 C 3 C n

Language: concept inheritance L 1 C 1 C 2 L 2 C 1 C 3

Language does not depend on any other language Independence Fragment does not depend on any other fragment

Independence Example Refrige rators

Homogeneous Fragment everything expressed with one language

Heterogeneous C Statemachines Testing Example Exten ded C

Domain Hierarchy

Domain Hierarchy automotive avionics embedded software all programs Example Exten ded C

Design Dimensions expressivity coverage semantics separation of concerns completeness paradigms modularity concrete syntax process

Expressivity expressivity coverage semantics separation of concerns completeness paradigms modularity concrete syntax process

Shorter Programs More Accessible Semantics

For a limited Domain! Domain Knowledge encapsulated in language

Smaller Domain More Specialized Language Shorter Programs

The do-what-i-want language Ѱ

Single Program vs. Class/Domain No Variability! Ѱ

Domain Hierarchy more specialized domains more specialized languages

Reification D n

Reification D n+1 == D n

Reification Transformation/ Generation Language Definition ==

Overspecification! Requires Semantic Analysis!

Linguistic Abstraction Declarative! Directly represents Semantics.

Def: DSL A DSL is a language at D that provides linguistic abstractions for common patterns and idioms of a language at D-1 when used within the domain D.

Def: DSL cont d A good DSL does not require the use of patterns and idioms to express semantically interesting concepts in D. Processing tools do not have to do semantic recovery on D programs. Declarative!

Semantics & Execution expressivity coverage semantics separation of concerns completeness paradigms modularity concrete syntax process

Static Semantics Execution Semantics

Static Semantics Execution Semantics

Static Semantics Constraints Type Systems

Unique State Names Unreachable States Dead End States Example Exten ded C

Unique State Names Unreachable States Dead End States Easier to do on a declarative Level! Example Exten ded C

Unique State Names Unreachable States Dead End States Easier to do on a declarative Level! Thinking of all constraints is a coverage problem! Example Exten ded C

Assign fixed types Derive Types Calculate Common Types Check Type Consistency What does a type system do?

Intent + Derive Check

Intent + Derive Check More code Better error messages Better Performance

Intent + Derive Check More code Better error messages Better Performance More convenient More complex checkers Harder to understand for users

What does it all mean? Execution Semantics

Def: Semantics via mapping to lower level OB: Observable Behaviour (Test Cases)

Def: Semantics via mapping to lower level L D Transformation Interpretation L D-1

Transformation D n+1 D n

Transformation Example Exten ded C

Transformation L D L D-1 Transformation Known Semantics!

Transformation L D Correct!? L D-1 Transformation

Transformation Tests (D) Tests (D-1) L D L D-1 Transformation Run tests on both levels; all pass. Coverage Problem!

Example Refrige rators

Transformation Example Pension Plans

Behavior Example Refrige rators

Multi-Stage L 3 L 2 Modularization L 1 L 0

Multi-Stage: Reuse L 3 L 2 L 5 L 1 Reusing Later Stages L 0 Optimizations!

Multi-Stage: Reuse L 3 Robot Control State Machine L 2 L 5 Components L 1 C (MPS tree) L 0 C Text Example Exten ded C

Multi-Stage: Reuse L 3 L 2 L 5 Robot Control State Machine Consistency Model Checking Components Efficient Mappings L 0 L 1 C Type System C (MPS tree) Syntactic Correctness, Headers C Text Example Exten ded C

Multi-Stage: Reuse L 3 Reusing Early Stages L 2 Portability L 1 L 1b L 0 L 0b

Multi-Stage: Reuse L 3 L 2 L 1 L 1b Java C# Example L 0 L 0b Exten ded C

Multi-Stage: Preprocess Adding an optional, modular emergency stop feature

Interpretation A program at D 0 that acts on the structure of an input program at D >0

Interpretation A program at D 0 that acts on the structure of an input program at D >0 imperative step through functional eval recursively declarative? solver?

Example Pension Plans

Example Refrige rators

Behavior Example Refrige rators

Transformation Interpretation

Transformation Interpretation + Code Inspection

Transformation Interpretation + Code Inspection OSGi Generators Example Compo nents

Transformation Interpretation + Code Inspection + Debugging

Transformation Interpretation + Code Inspection + Debugging Platform Interactions Example Refrige rators

Transformation Interpretation + Code Inspection + Debugging + Performance & Optimization

Transformation Interpretation + Code Inspection + Debugging + Performance & Optimization Efficiency for Real-Time S/w Memory Use Example Exten ded C

Transformation Interpretation + Code Inspection + Debugging + Performance & Optimization + Platform Conformance

Transformation Interpretation + Code Inspection + Debugging + Performance & Optimization + Platform Conformance Web Frameworks and Standards Example Web DSL

Transformation + Code Inspection Interpretation + Turnaround Time + Debugging + Performance & Optimization + Platform Conformance

Transformation + Code Inspection + Debugging Interpretation + Turnaround Time Testing + Performance & Optimization + Platform Conformance Example Pension Plans Example Refrige rators

Transformation + Code Inspection + Debugging Interpretation + Turnaround Time + Runtime Change + Performance & Optimization + Platform Conformance

Transformation + Code Inspection + Debugging + Performance & Optimization + Platform Conformance Interpretation + Turnaround Time + Runtime Change Change Business Rules without Redeployment Example Pension Plans

Def: Semantics via mapping to lower level L D Transformation Interpretation L D-1

Multiple Mappings at the same time L D L x L y L z Similar Semantics?

Multiple Mappings at the same time L D T Similar Semantics? L x L y L z T T T all green!

Example Pension Plans

Example Refrige rators

Reduced Expressiveness bad? maybe. good? maybe!

Reduced Expressiveness bad? maybe. good? maybe! Model Checking SAT Solving Exhaustive Search, Proof!

Unique State Names Unreachable States Dead End States Guard Decidability Reachability Exhaustive Search, Proof!

Example Exten ded C

Example Exten ded C

Separation of Concerns expressivity coverage semantics separation of concerns completeness paradigms modularity concrete syntax process

Several Concerns in one domain

Several Concerns in one domain integrated into one fragment separated into several fragments

Viewpoints independent dependent

Viewpoints Hardware Behavior Tests Example Refrige rators

Viewpoints: Why? Sufficiency Different Stakeholders Different Steps in Process VCS unit!

Viewpoints Hardware Product Management Behaviour Thermodynamics- Experts Tests Example Refrige rators

Viewpoints independent sufficient? contains all the data for running a meaningful transformation

Viewpoints sufficient Hardware structure documentation sufficient implementation code Example Refrige rators

Viewpoints: Why? 1:n Relationships

Viewpoints Hardware 1:n Behaviour Tests Example Refrige rators

Viewpoints Well-defined Dependencies No Cycles! Avoid Synchronization! (unless you use a projectional editor)

Language Modularity expressivity coverage semantics separation of concerns completeness paradigms modularity concrete syntax process

Language Modularity, Behavior Composition and Reuse (LMR&C) increase efficiency of DSL development

Language Modularity, Behavior Composition and Reuse (LMR&C) increase efficiency of DSL development 4 ways of composition: Referencing Reuse Extension Reuse

Language Modularity, Behavior Composition and Reuse (LMR&C) increase efficiency of DSL development 4 ways of composition: distinguished regarding dependencies and fragment structure

Dependencies: Behavior do we have to know about the reuse when designing the languages?

Dependencies: Behavior do we have to know about the reuse when designing the languages? Fragment Structure: homogeneous vs. heterogeneous ( mixing languages )

Behavior Dependencies & Fragment Structure:

Referencing

Referencing Dependent No containment

Referencing Used in Viewpoints

Referencing Fragment Fragment Fragment

Referencing Example Refrige rators

Extension

Extension Dependent Containment

Extension more specialized domains more specialized languages

Extension D n+1 == D n

Extension D n+1 == D n

Extension Good for bottom-up (inductive) domains, and for use by technical DSLs (people) D n ==

Extension Behavior Drawbacks tightly bound to base potentially hard to analyze the combined program

Extension Example Exten ded C

Extension Example Exten ded C

Embedding

Embedding

Embedding Independent Containment

Embedding Example Pension Plans

Embedding Behavior Embedding often uses Extension to extend the embedded language to adapt it to its new context.

Concrete Syntax expressivity coverage semantics separation of concerns completeness paradigms modularity concrete syntax process

UI for the language! Important for acceptance by users! Textual Symbolic Tabular Graphical

Reuse existing syntax of domain, if any! Tools let you freely combine all kinds.

Default: Text Editors simple to build Productive Easy to integrate w/ tools Easy to evolve programs

Default: Text Editors simple to build Productive Easy to integrate w/ tools Easy to evolve programs then add other forms, if really necessary

Graphical in case Relationships

Graphical in case Flow and Depenency

Graphical in case Causality and Timing

Symbolic Either Mathematical, or often highly inspired by domain

Tables

Combinations

Combinations

Combinations

Combinations

The End. @markusvoelter +Markus Voelter