An Evaluation of Domain-Specific Language Technologies for Code Generation

Similar documents
A Multi-layered Domain-specific Language for Stencil Computations

Spoofax: An Extensible, Interactive Development Environment for Program Transformation with Stratego/XT

SERG. Spoofax: An Extensible, Interactive Development Environment for Program Transformation with Stratego/XT

Language Extension and Composition with Language Workbenches

Renaud Durlin. May 16, 2007

Generation of Multigrid-based Numerical Solvers for FPGA Accelerators

What do Compilers Produce?

... is a Programming Environment (PE)?... is Generic Language Technology (GLT)?

CS152 Programming Language Paradigms Prof. Tom Austin, Fall Syntax & Semantics, and Language Design Criteria

Domain-Specific Languages for Composable Editor Plugins

Formats of Translated Programs

COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher

CMSC 330: Organization of Programming Languages. Context Free Grammars

Compiler construction

Semantic Modularization Techniques in Practice: A TAPL case study

The Structure of a Syntax-Directed Compiler

Portable Editor Services

The Structure of a Compiler

Index. Comma-separated values (CSV), 30 Conditional expression, 16 Continuous integration (CI), 34 35, 41 Conway s Law, 75 CurrencyPair class,

Compilers and computer architecture From strings to ASTs (2): context free grammars

Domain-Specific Languages Language Workbenches

10 Thoughts 2 Demos * Discussions

INF5110 Compiler Construction

Declaratively Defining Domain-Specific Language Debuggers

History of Compilers The term

Abstract Syntax Sucks!

Automatic Generation of Algorithms and Data Structures for Geometric Multigrid. Harald Köstler, Sebastian Kuckuk Siam Parallel Processing 02/21/2014

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

What is a compiler? Xiaokang Qiu Purdue University. August 21, 2017 ECE 573

Enabling PHP Software Engineering Research in Rascal

M : an Open Model for Measuring Code Artifacts

Introduction to Compiler Design

Challenges in Fully Generating Multigrid Solvers for the Simulation of non-newtonian Fluids

ABAP DSL Workbench SAP TechED 2016

SPIN s Promela to Java Compiler, with help from Stratego

Better Extensibility through Modular Syntax. Robert Grimm New York University

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

Introduction to Dependable Systems: Meta-modeling and modeldriven

Undergraduate Compilers in a Day

The Structure of a Syntax-Directed Compiler

Yacc: A Syntactic Analysers Generator

Grammars and Parsing. Paul Klint. Grammars and Parsing

Compiling and Interpreting Programming. Overview of Compilers and Interpreters

LECTURE 3. Compiler Phases

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

Compilers. History of Compilers. A compiler allows programmers to ignore the machine-dependent details of programming.

C++- und Ruby- und... Refactoring für Eclipse

9/5/17. The Design and Implementation of Programming Languages. Compilation. Interpretation. Compilation vs. Interpretation. Hybrid Implementation

UPTR - a simple parse tree representation format

PEG-Based Language Workbench

CST-402(T): Language Processors

Syntax and Grammars 1 / 21

SERG. The Spoofax Language Workbench Rules for Declarative Specification of Languages and IDEs

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

When do We Run a Compiler?

COP 3402 Systems Software Syntax Analysis (Parser)

Compilers and Interpreters

Course introduction. Advanced Compiler Construction Michel Schinz

Crafting a Compiler with C (II) Compiler V. S. Interpreter

Domain-Specific Languages

Why are there so many programming languages? Why do we have programming languages? What is a language for? What makes a language successful?

Semantics driven disambiguation A comparison of different approaches

CS 415 Midterm Exam Spring SOLUTION

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics

COMP 181. Prelude. Prelude. Summary of parsing. A Hierarchy of Grammar Classes. More power? Syntax-directed translation. Analysis


Interpreters. Prof. Clarkson Fall Today s music: Step by Step by New Kids on the Block

Compositional Model Based Software Development

What is a compiler? var a var b mov 3 a mov 4 r1 cmpi a r1 jge l_e mov 2 b jmp l_d l_e: mov 3 b l_d: ;done

TDDD55- Compilers and Interpreters Lesson 3

The Structure of a Syntax-Directed Compiler

Reading Assignment. Scanner. Read Chapter 3 of Crafting a Compiler.

COMPILER CONSTRUCTION LAB 2 THE SYMBOL TABLE. Tutorial 2 LABS. PHASES OF A COMPILER Source Program. Lab 2 Symbol table

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

Relating Meta modelling and Concrete Textual Syntax

Working of the Compilers

Building an IDE with Rascal

Contents. Chapter 1 SPECIFYING SYNTAX 1

CS131 Compilers: Programming Assignment 2 Due Tuesday, April 4, 2017 at 11:59pm

Compiling Regular Expressions COMP360

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

COSE312: Compilers. Lecture 1 Overview of Compilers

Inside PHP Tom OSCON th July, 2012

TDDD55 - Compilers and Interpreters Lesson 3

Domain-Specific. Languages. Martin Fowler. AAddison-Wesley. Sydney Tokyo. With Rebecca Parsons

Compiling Techniques

A Survey on Domain-Specific Languages in Robotics

COLLEGE OF ENGINEERING, NASHIK. LANGUAGE TRANSLATOR

sbp: A Scannerless Boolean Parser

Pioneering Compiler Design

COMPILER CONSTRUCTION Seminar 02 TDDB44

Structure of a compiler. More detailed overview of compiler front end. Today we ll take a quick look at typical parts of a compiler.

Scripting a Refactoring with Rascal and Eclipse. Mark Hills, Paul Klint, & Jurgen J. Vinju

COP 3402 Systems Software. Lecture 4: Compilers. Interpreters

Syntax-Directed Translation. Lecture 14

The TTC 2014 FIXML Case: Rascal Solution

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

Eclipse Support for Using Eli and Teaching Programming Languages

Domain-Specific Languages for Digital Forensics

CMPE 152 Compiler Design

Transcription:

An Evaluation of Domain-Specific Language Technologies for Code Generation Christian Schmitt, Sebastian Kuckuk, Harald Köstler, Frank Hannig, Jürgen Teich Hardware/Software Co-Design, System Simulation, Friedrich-Alexander University Erlangen-Nürnberg (FAU) ICCSA 2014, Guimaraes, Portugal; July 01, 2014

Challenges for Software Development in Computational Science and Engineering Current Situation Hardware: Modern HPC clusters are massively parallel and heterogeneous Applications: Become more complex with increasing computation power Algorithm: Solvers are general ideas that need specialised implementation and parameter settings : Software development has to address these issues! 1

Idea: Abstraction of Solution Implementation Separate the solver algorithm from its implementation to allow end users to Focus on solving their mathematical problems Rapidly evaluate different solution approaches Easily run solvers on a large scale of hardware platforms with near-optimal performance 2

Idea: Abstraction of Solution Implementation Separate the solver algorithm from its implementation to allow end users to Focus on solving their mathematical problems Rapidly evaluate different solution approaches Easily run solvers on a large scale of hardware platforms with near-optimal performance convergence rate grid size 2

Idea: Abstraction of Solution Implementation Separate the solver algorithm from its implementation to allow end users to Focus on solving their mathematical problems Rapidly evaluate different solution approaches Easily run solvers on a large scale of hardware platforms with near-optimal performance 2

Domain-Specific Language (DSL) Definitions Domain-Specific Languages: An Annotated Bibliography, Arie van Deursen, Paul Klint, und Joost Visser: A domain-specific language (DSL) is a programming language or executable specification language that offers, through appropriate notations and abstractions, expressive power focused on, and usually restricted to, a particular problem domain. Domain-Specific Languages, Martin Fowler: Domain-specific language: a computer programming language of limited expressiveness focused on particular domain. : Talk about what should be computed, not how. (declarative vs. imperative) 3

Two Approaches to Creating DSLs Internal / embedded DSLs Utilise general-purpose programming languages (host language) Extension or restriction of the host language (or both at the same time) Extensions possible in form of libraries (e. g., data types, objects, methods), annotations, macros, etc. Same syntax as host language and often same compiler or interpreter External DSLs Completely newly defined programming languages More flexible and expressive than internal DSLs Syntax and semantics defined freely, but often related to existing languages Potential to create a powerful semantic model as intermediate representation (IR) 4

Basics & Technologies

Basics Goal Build a textual external DSL for solving PDEs via the multigrid method. Lexer Also called tokenizer or scanner Splits textual input into stream of tokens Output is fed into the parser Parser Matches stream of tokens to rules Executes code depending on matched rule Specification of parser rules in Grammar Different parser types exist 5

Spoofax Language Workbench based on Eclipse platform Development started in 2007 SWERL group at TU Delft, Netherlands License: GNU LGPL Specification of grammar via Syntax Definition Formalism (SDF) : scannerless parser generated automatically Automatic generation of a DSL IDE with syntax highlighting, code folding, bracket matching, etc. Transformation specification via Stratego: Matching via rules and optional conditions Context-sensitive transformations via strategies and dynamic rewrite rules 6

Rascal MPL Meta-Programming Language (MPL) based on the Java VM In development since late 2008 License: Eclipse Public License (EPL) Developer: SWAT group at CWI Amsterdam, Netherlands Syntactic features based on SDF Generation of scannerless parser Transformation features similar to Stratego Available as plugin for Eclipse and command-line REPL 7

Custom Approaches C++ based Utilises popular tools Flex for tokenizing and Bison for parsing Construction of a parse tree that is transformed to an Abstract Syntax Tree (AST) boost::function and C ++ 11 lambdas and function binding for node matching Scala based Object-functional language based on the Java VM In development since 2001 and released to the public in 2004 License: BSD-Style Developer: EPF Lausanne, Switzerland Different lexer and parser types integrated 8

Methodology & Comparison

Methodology General idea Take a fixed amount of time to spend on each technology: 3 weeks Set goal: Transformation of a simple DSL to C ++ code: Generate simple numerical solver for Poisson s equation Weighted rating of technologies according to pre-defined criteria Workflow 1. Define semantics of DSL program (input) 2. Define expected output: manually write example solver that is to be generated 3. Think about needed transformations to convert input into output code 4. Implement parsing, transformations and output in each technology 9

Criteria Sort criteria into two orthogonal groups: Core & environment criteria Core criteria concern the technology itself Environment criteria refer to a technology s surroundings Hard & soft criteria Hard criteria have to be fulfilled Soft criteria are optional goodies Weighting is adjusted depending on group combination. Our weights are: core environment hard 5 soft 1 3 1 3 For each criterion, points in the range [ 2; 2] are assigned. 10

Some of our Criteria Explanation: core, environment hard Development status, Expressivity, License soft Code structuring, Components, Concepts, Debugging, Dependencies, Developer IDE, Development activity, Development team, Documentation, Grammar, IDE Generation, User-base size 11

Results: Total Points per Technology Scala CPP Rascal Spoofax Core Environment 0 20 40 60 80 max. core points: 60; max. environment points: 24 12

Results: Example discussion Criterion w Spoofax Rascal C++ Scala Core criteria: Development status hard 5-1 0 2 2 Development status denotes the maturity of a technology We experienced slow-downs and a few crashes with Spoofax Rascal relies on hidden assumptions that are hardly/not at all documented and subject to further change by its authors The C ++ builds on the mature Flex and Bison tools We did not experience any bugs or hidden assumptions in Scala 13

Conclusions Technology rating Specialised approaches Spoofax and Rascal loose core points for Development phase External dependencies Debugging mechanisms Chicken-egg problem in environment criteria: Lack of documentation quantity and examples because of small user base size and vice versa Rating methodolgy Categorisation of criteria based on our requirements Weights adjusted to our needs : adjust to your own needs! 14

Summary & Outlook

Summary Discussed in this talk Idea of DSLs Internal / external DSLs Four approaches to the creation of external textual DSLs Methodology for evaluation of DSL implementation technologies Subjective comparison of four technologies at one point in time : Take-home message: DSLs are fun to work on! Future work Language Definition for our DSL Transformation framework and supporting infrastructure Optimisation of the generated programs 15

Thanks for listening. Questions? 16