Developing Domain-Specific Languages for the JVM Travis Dazell Systems Architect Digi-Key Corporation.

Slides:



Advertisements
Similar presentations
The case for Speech March, Think of the following kinds of applications … Do they have something in common? 2 ? ?
Advertisements

Elevator Simulator DSL Project Presented by Miguel Garzón and Stéphane Leblanc 1.
ANTLR in SSP Xingzhong Xu Hong Man Aug Outline ANTLR Abstract Syntax Tree Code Equivalence (Code Re-hosting) Future Work.
Documentation Generators: Internals of Doxygen John Tully.
Domain Specific Embedded Languages Lecture 2, Designing and Using Combinators John Hughes.
Filling the Gap Between System Design & Performance Verification Rafik HENIA, Laurent RIOUX, Nicolas SORDON Thales Research & Technology.
© Applied Abstractions applied-abstractions.com Textual DSLs Textual DSLs illustrated with Eclipse Tools Sven Efftinge
SableCC SableCC is developed by professors and graduate students at McGill University and is open source (licensed under the Apache License, Version 2.0)‏
So far.. We have covered a) Requirements gathering: observation & interview. b) Requirements specification. c) Requirements validation. d) Design/paper.
WPSM Programming Language A simple language that transform simple data structure into complex xML format Wai Y. Wong Peter Chen Seema Gupta Miqdad Mohammed.
1/18 CS 693/793 Lecture 09 Special Topics in Domain Specific Languages CS 693/793-1C Spring 2004 Mo, We, Fr 10:10 – 11:00 CH 430.
Whole Platform Tesi di Dottorato di: RICCARDO SOLMI Università degli Studi di Bologna Facoltà di scienze matematiche, fisiche e naturali Corso di Dottorato.
Groovy & Grails Jean Barmash CTO, EnergyScoreCards.com
1 Programming Languages Examples: C, Java, HTML, Haskell, Prolog, SAS Also known as formal languages Completely described and rigidly governed by formal.
ANTLR with ASTs. Abstract Syntax Trees ANTLR can be instructed to produce ASTs for the output of the parser ANTLR uses a prefix notation for representing.
ANTLR.
ANTLR Andrew Pangborn & Zach Busser. ANTLR in a Nutshell ANother Tool for Language Recognition generates lexers generates parsers (and parse trees)‏ Java-based,
Overview of JSP Technology. The need of JSP With servlets, it is easy to – Read form data – Read HTTP request headers – Set HTTP status codes and response.
Flirting With The Dark Side Domain Specific Languages and AI.
Introducing Java.
The purpose of this project is to bridge the learning gap in learning programming tools by providing an easy to learn, English-like language that allows.
Sumant Tambe, et. al LEESA DSPD 2008 An Embedded Declarative Language for Hierarchical Object Structure Traversal Sumant Tambe* Aniruddha Gokhale Vanderbilt.
Bridging the chasm between MDE and the world of compilation Nondini Das 1.
Xactium xDSLs Run Models Not Code Tony Clark
Introduction to “Oslo” Jeremy Boyd Director – Mindscape MSDN Regional Director
VeribisCRM CUSTOMER RELATIONSHIP MANAGEMENT Engin Duran Experience is our know how.
Workshop on Integrated Application of Formal Languages, Geneva J.Fischer Mappings, Use of MOF for Language Families Joachim Fischer Workshop on.
Sumant Tambe, et. al LEESA DSPD 2008 An Embedded Declarative Language for Hierarchical Object Structure Traversal Sumant Tambe* Aniruddha Gokhale Vanderbilt.
Getting Started with ANTLR Chapter 1. Domain Specific Languages DSLs are high-level languages designed for specific tasks DSLs include data formats, configuration.
Compuware Corporation Business Driven SOA Edwin Schumacher Director of Product Management
1 Extending Java And Developing DSLs With Open Source Language Workbench JetBrains MPS Konstantin Solomatov JetBrains Lead Developer for JetBrains MPS.
Boardr The Racing Board Game Creation Language. Project Manager: Eric Leung Language and Tools Guru: Shensi Ding System Architect: Seong Jin Park System.
Key Challenges for Modeling Language Creation by Demonstration Hyun Cho, Jeff Gray Department of Computer Science University of Alabama Jules White Bradley.
Language Features As A Library Using Gosu’s Open Type System With External DSLs Carson Gross Languages Amalgamated Code
Domain-Specific Development Stuart Kent, Senior Program Manager, DSL Tools, Visual Studio Team System, Microsoft.
Programming Languages & Translators (CE 359) Fall 2013 Prof. Dr: Ahmed El Nahass Lecture 1 1 FACULTY OF ENGINEERING COMPUTER ENGINEERING Prof.Dr Ahmed.
Domain Specific Languages in Erlang Dennis Byrne
DEV-05: Ratcheting up your OpenEdge™ Development Productivity Sunil S Belgaonkar Principal Software Engineer.
A Little Language for Surveys: Constructing an Internal DSL in Ruby H. Conrad Cunningham Computer and Information Science University of Mississippi.
Object-Oriented Analysis and Design Fall 2009.
INRIA - LaBRICharles Consel Jan-06 1 Domain-Specific Software Engineering Charles Consel Phoenix Research Group LaBRI /INRIA-Futurs January 2006.
Automated Transformation of Statements Within Evolving Domain Specific Languages Peter Bell CEO/CTO, SystemsForge 7th OOPSLA Workshop on Domain-Specific.
From POSL to d-POSL: Making the Positional-Slotted Language Defeasible Advisors: Nick Bassiliades, Efstratios Kontopoulos Instructor: Dr. Harold Boley.
XML Grammar and Parser for WSOL Kruti Patel, Vladimir Tosic, Bernard Pagurek Network Management & Artificial Intelligence Lab Department of Systems & Computer.
Towards the better software metrics tool motivation and the first experiences Gordana Rakić Zoran Budimac.
Semantics for DSL Group Members: Ritu Arora, Diyang Chu, Zekai Demirezen, Jeff Gray, Jacob Gulotta, Luis Pedro, Arturo Sanchez, Greg Sullivan,Ximing Yu.
Software Requirements: A More Rigorous Look 1. Features and Use Cases at a High Level of Abstraction  Helps to better understand the main characteristics.
Cross Language Clone Analysis Team 2 October 13, 2010.
Weaving a Debugging Aspect into Domain-Specific Language Grammars SAC ’05 PSC Track Santa Fe, New Mexico USA March 17, 2005 Hui Wu, Jeff Gray, Marjan Mernik,
Software Product Lines Peter Bell CEO/CTO, SystemsForge cf.Objective() 2008 Peter Bell CEO/CTO, SystemsForge cf.Objective() 2008.
The Interpreter Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools
Introduction. Introduction Traditional view of a compiler tool to translate high-level (imperative) code into optimized machine code large, complicated.
The Spoofax Language Workbench Rules for Declarative specification of language and IDEs Lennart C. L. Kats and Eelco Visser Delft University of Technology.
Advanced Software Development Karl Lieberherr CSG 260 Fall Semester
Presented by: Elena C. Ciobanu Mihai V. Ciobanu Kuntal Ghosh
FUNCTIONAL PROGRAMING AT WORK - HASKELL AND DOMAIN SPECIFIC LANGUAGES Dr. John Peterson Western State Colorado University.
Why is Design so Difficult? Analysis: Focuses on the application domain Design: Focuses on the solution domain –The solution domain is changing very rapidly.
Open Source Compiler Construction (for the JVM)
Introduction to Compiler Construction
Writing a Simple DSL Compiler with Delphi
A quick introduction.
Implementing Language Extensions with Model Transformations
Interpreter Pattern.
Agile testing for web API with Postman
Semantic Markup for Semantic Web Tools:
Parsing with IRONY Roman Ivantsov, MCSD
Implementing Language Extensions with Model Transformations
Groovy.
Presentation transcript:

Developing Domain-Specific Languages for the JVM Travis Dazell Systems Architect Digi-Key Corporation

Outline What is a Domain Specific Language (DSL)? Internal Versus External DSLs Internal DSLs Java Example without a DSL Improved Java Example using Internal DSL Patterns Groovy for Internal DSLs External DSLs Writing a new language to solve our example problem ANTLR JetBrains MPS Scala Parser Combinators

What is a DSL? DSLs have been around for a long time SQL, CSS, Regular Expressions DSLs are small languages, focused on a specific problem DSLs are easy to use and understand, even for a non- programmer Often accomplished through layers of abstraction The DSL language relates directly to the problem domain

Example Problem: Golf Course Scheduler To demonstrate how DSLs can be used, we’ll look at writing a simple language for scheduling tee times at a golf course

Our Goal Before TeeTime teeTime = new TeeTime(); teeTime.setTime(“Sep :15 PM”); Golfer golfer = new Golfer(); golfer.setFirstName(“Travis”); golfer.setLastName(“Dazell”); golfer.setNumberOfGuests(3); teeTime.setGolfer(golfer); TeeTimeScheduler.schedule(teeTime); After (as a DSL) new tee time at Sep :15 PM for Travis Dazell and 3 guests

Java Example with the Builder Pattern Live Coding Demo

Can We Make the Java DSL Even Better? An internal Java DSL is limited by the inherent language constraints Semi-colons are required Parentheses for invoking methods are not optional Dots cannot be avoided when dispatching methods We often need to build a significant amount of indirection to achieve an expressive DSL Example: Builder Pattern

Let’s Make the DSL Groovy Live Coding Demo

Solving the Problem with a Groovy DSL Optional semicolons We can omit parentheses in many cases Closures methodMissing Metaprogramming DSL Descriptors for syntax highlighting and help hovers

Using External DSLs What happens when we need to step outside of a host language? External DSLs are custom languages We write a grammar to define the syntax for our language We need to write a lexer and parser We may need to perform semantic analysis We need to write an interpreter or code generator Thankfully, there are tools that make this easier

ANTLR Live Coding Demo

ANTLR Review We define our EBNF grammar We can mix Java code into our grammar for processing input scripts Note that ASTs can be constructed for more complex processing ANTLR will generate the lexer and parser for us

Scala Parser Combinators Live Coding Demo

Scala Parser Combinators Review You have the privilege of working entirely within Scala You define parsing rules in an EBNF-like format You combine each of your parsing rules to form your DSL syntax Like the other examples, you can interpret the input and generate whatever output you need

JetBrains MPS Live Coding Demo

JetBrains MPS Review Takes DSL design to a more abstract level You work on the concepts and structure of your DSL, instead of the low-level grammar You do very little, if any, traditional coding in the IDE You can generate all kinds of output. We auto-generated Java code in this example You can test your DSLs within the MPS IDE or export your generated Java code to another IDE for integration

Applying DSLs in Your Projects Adapt legacy code Wrapper APIs Develop a DSL for a particular sub-system (i.e. domain) of your application Flesh-out requirements and test cases Using a DSL to code your business rules can help bridge the gap from requirements to implementation You can show DSL source code to a business analyst and they’ll understand it completely Enhancing custom IT tasks Operators, System Administrators

References Debasish Ghosh, DSLs In Action, Manning, 2011 Fergal Dearle, Groovy for Domain-Specific Languages, PACKT, 2010 Cay S. Horstmann, Scala for the Impatient, Addison-Wesley, 2012 Martin Fowler, Domain-Specific Languages, 2010 Markus Voelter, DSL Engineering: Designing, Implementing, and Using Domain-Specific Languages, 2013

Related JavaOne Sessions Attend these JavaOne sessions to learn more Embedded DSL: Groovy and Scala Fair Duel Monday 4:30 PM – 6:30 PM, Hilton Continental Ballroom 1/2/3 BOF2893: Scala Parser Combinators Tuesday 7:30 PM – 8:15 PM, Hilton Yosemite B/C CON5389: Groovy DSLs: Beginner to Expert Wednesday 11:30 AM-12:30 PM, Hilton Golden Gate 4/5 CON2077: Integrating JVM Languages Thursday 12:30 PM – 1:30 PM, Hilton Yosemite B/C

Conclusion DSLs allow you to develop software using syntax that fits within the problem domain Internal DSLs can be written in many JVM languages Other JVM languages are also well-suited for internal DSL development, such as JRuby, Clojure, and Scala External DSLs give you the flexibility to design the language any way you want More involved, but thanks to tools like ANTLR, JetBrains MPS, and Scala Parser Combinators, this isn’t difficult

Miscellaneous Contact Information: Code examples are available on GitHub: Follow me: Blog: travisdazell.blogspot.com

Questions?