SlideShare a Scribd company logo
1 of 29
Download to read offline
Type-safe DSLs
Using Xtext/TS, Xtend, Groovy and
other languages
             Werner Keil

        Eclipse DemoCamp Hamburg
             14th June 2012
Our Goal


          AVOIDING ARITHMETIC OR
          TYPE ERRORS IN A DSL

2   © 2007-2012 Creative Arts & Technologies
Overview
• Introduction
       • What is a DSL?
       • Internal and External DSLS
       • Type-Safety

• Units and Healthcare
       • Unit-API, UOMo
       • UCUM, HL7, Groovy used by Healthcare

• Other Languages
       • Jython/WLST
       • Xtext/Xbase/Xtend
       • Scala, Fantom, F#

• Demo
• Q&A
3   © 2007-2012 Creative Arts & Technologies
Who am I?
Werner Keil




                 • Consultant – Coach
                 • Creative Cosmopolitan
                 • Open Source Evangelist
                 • Software Architect
                 • Java Godfather
                 • …


                     Twitter @wernerkeil

4   © 2007-2012 Creative Arts & Technologies
What is a DSL?
• A DSL is a computer language
  (specification, modeling, programming) tailored to
  a particular domain. But, what is a domain?
• DSL examples: SQL, CSS, Sawzall (Google)

• Gains in expressiveness and ease of use (the
  future could be end-user programming)
• Gains in productivity
• Reduced maintenance costs

5   © 2007-2012 Creative Arts & Technologies
What is a Domain?
                             Real-Time                      Business
                               Systems                      Systems

                                                                            Requirements




                                                                             Specification


                             Aircraft            Patient       Insurance
                             control           Management    Management    Implementation
                           systems              Systems        Systems


                                                                             Deployment



6   © 2007-2012 Creative Arts & Technologies
Internal Domain Specific Languages
• These are languages built using the syntactic
  elements of the underlying language
• In the case of Java, building a DSL using Java
  classes and methods
• With other JVM-based languages, that’s usually
  similar, Java code generated in many cases




7   © 2007-2012 Creative Arts & Technologies
External Domain Specific Languages
• External DSLs
       • Written in a different language than the main (host) language of the
         application
       • Transformed into it using some form of compiler or interpreter

• May include
       • XML configuration files
       • Plain text configuration files
       • Full-blown languages




8   © 2007-2012 Creative Arts & Technologies
Type-Safety
• Java does not have strongly typed primitive types
  (like e.g. Ada language).
• For performance reasons most developer prefer
  primitive types over objects in their interface.
• Primitives type arguments often lead to name
  clashes (methods with the same signature)




9   © 2007-2012 Creative Arts & Technologies
What do these disasters have in common?
• Patriot Missile
  The cause was an inaccurate calculation of the
  time since boot due to a computer arithmetic error.
• Ariane 5 Explosion
  The floating point number which a value was
  converted from had a value greater than what
  would be represented by a 16 bit signed integer.



10   © 2007-2012 Creative Arts & Technologies
What do these disasters have in common?
• Gimli Glider (near disaster)
     Fuel loading was miscalculated through misunderstanding of the
     recently adopted Metric System, replacing the Imperial System
• Mars Orbiter
     Preliminary findings indicate that one team used English units (e.g. inches,
     feet and pounds) while the other used metric units for a key spacecraft
     operation.
        • NASA lost a $125 million Mars orbiter because a Lockheed Martin engineering team used
          English units of measurement while the agency's team used the more conventional metric
          system for a key spacecraft operation
        • This also underlines the added risk when 3 rd party contractors are involved or projects are
          developed Offshore




11    © 2007-2012 Creative Arts & Technologies
Unit Tests wouldn‘t find these…
  Despite their name
• All previous example illustrate three categories of
  errors difficult to find through Unit Testing:
       • Interface Errors (e.g. millisecond/second, radian/degree, meters/feet).
       • Arithmetic Errors (e.g. overflow).
       • Conversion Errors.




17   © 2007-2012 Creative Arts & Technologies
SQL Example with Errors
     StringBuilder sql = new StringBuilder();
     sql.append("SELECT o.sum,(SELECT first_name,last_name");
     sql.append("                                       FROM person p");
     sql.append("                                      WHERE o.person_id=p.id) AS
     client");
     sql.append(" FROM order o");
     sql.append("WHERE o.id = "+orderId);
     sql.append("                               AND o.status_code IN (?,?)");
     PreparedStatement stmt =
     conn.prepareStatement(sql.toString());
     stmt.setString(1, "PAID");


     //...

19   © 2007-2012 Creative Arts & Technologies
Typesafe SQL Example
     Person p = new Person();
     List<Tuple<String, Integer, Date>> rows =
           new QueryBuilder(datasource)
                 .from(p)
                 .where(gt(p.height, 170))
                 .select(p.name, p.height, p.birthday)
                 .list();
     for (Tuple<String, Integer, Date> row : rows) {
           String name = row.v1;
           Integer height = row.v2;
           Date birthday = row.v3;
           System.out.println(
           name + " " + height + " " + birthday);
     }
20   © 2007-2012 Creative Arts & Technologies
Unit-API | Operations


   Results with
   Same Dimension               Different Dimension

   Binary Operations            Binary Operations

   add(double) or (long)        root(int)

   multiply(double) or (long)   power(int)

   divide(double) or (long)     multiply(Unit)

   compound(Unit)               divide(Unit)

   Unary Operations

   inverse()
UOMo UCUM

          Unified Code for Units of Measure
          The Unified Code for Units of Measure is inspired by
           and heavily based on
          • ISO 2955-1983
          • ANSI X3.50-1986
          • HL7's extensions called ISO+



25   © 2007-2012 Creative Arts & Technologies
HL7 DSL
     def mySegment = ...                                    // assignment to another
     NK1 segment instance
     def group = message.PATIENT_RESULT(0).PATIENT
     group.NK1(0) = 'abc'                                   // syntax error!
     msg1.NK1(0) = mySegment                                // syntax error!
     msg1.NK1(0).from(mySegment)                            // works!

     def nk1                                = message.PATIENT_RESULT(0).PATIENT.NK1(0)
     def otherNk1 = message.PATIENT_RESULT(0).PATIENT.NK1(0)
     nk1[4]                                 = otherNk1[4]    // copy address
     nk1[4][4]                              = otherNk1[4][4] // copy state or province
     only
     nk1[4][4].from(otherNk1[4][4])// equivalent
     nk1[4][4]                              = 'NY'   // set state or province directly

26   © 2007-2012 Creative Arts & Technologies
Healthcare DSL with Groovy




  DEMO
Jython
     /** * Java calculator class that contains two simple
     methods */
     public class Calculator {
                      public Calculator(){ }
                      public double calculateTip(double cost, double
                        tipPercentage) {
                                         return cost * tipPercentage;
                      }
                      public double calculateTax(double cost, double
                        taxPercentage) {
                                         return cost * taxPercentage;
                      }
     }


28   © 2007-2012 Creative Arts & Technologies
Jython (2)
     import Calculator
     from java.lang import Math
     class JythonCalc(Calculator):
     def __init__(self):
                      pass
     def calculateTotal(self, cost, tip, tax):
                      return cost + self.calculateTip(tip) + self.calculateTax(tax)
     if __name__ == "__main__":
                      calc = JythonCalc()
                      cost = 23.75
                      tip = .15
                      tax = .07
     print "Starting Cost: ", cost
     print "Tip Percentage: ", tip
     print "Tax Percentage: ", tax
     print Math.round(calc.calculateTotal(cost, tip, tax))


29   © 2007-2012 Creative Arts & Technologies
Jython (3)

          Result
     Starting Cost: 23.75
     Tip Percentage: 0.15
     Tax Percentage: 0.07
     29




30   © 2007-2012 Creative Arts & Technologies
Xtext Examples




  DEMO
Scala, Fantom, F#
• Scala
       • Functional programming language. Type-safe, as the company driving it was
         called.
       • Very popular for DSLs

• Fantom
       • Functional programming language
       • Units of Measurement support built in.
       • Runs on both JVM and CLR

• F#
       • Functional programming language
       • Units of Measurement support built in.

33   © 2007-2012 Creative Arts & Technologies
Scala and Fantom Examples




  DEMO
Links

   Eclipse – Project UOMo
   http://www.eclipse.org/uomo/


   Units of Measurement API
   http://www.unitsofmeasurement.org


   UCUM
   http://www.unitsofmeasure.org
Links (2)

   OpenHealth Project
   http://www.openhealth.org

   Groovy DSL Example
   http://groovy.dzone.com/news/domain-
   specific-language-unit-

   Jython
   http://www.jython.org
Links (3)

   Xtext
   http://www.eclipse.org/xtext


   Scala DSLs
   http://www.scala-lang.org/node/1403


   Fantom
   http://fantom.org/
Let‘s talk

Q&A
Contact

          werner@catmedia.us
                   or
          uomo@catmedia.us


          Twitter: @wernerkeil
          Hashtag #EclipseUOMo

More Related Content

What's hot

Quantified Social und das Internet der Dinge
Quantified Social und das Internet der DingeQuantified Social und das Internet der Dinge
Quantified Social und das Internet der DingeWerner Keil
 
Social Media Week 2015 - Quantified Self and the Social Internet of Things
Social Media Week 2015 - Quantified Self and the Social Internet of ThingsSocial Media Week 2015 - Quantified Self and the Social Internet of Things
Social Media Week 2015 - Quantified Self and the Social Internet of ThingsWerner Keil
 
USING VISION SENSORS FOR INNOVATIVE HCI
USING VISION SENSORS FOR INNOVATIVE HCIUSING VISION SENSORS FOR INNOVATIVE HCI
USING VISION SENSORS FOR INNOVATIVE HCIRakuten Group, Inc.
 
"Using Deep Learning for Video Event Detection on a Compute Budget," a Presen...
"Using Deep Learning for Video Event Detection on a Compute Budget," a Presen..."Using Deep Learning for Video Event Detection on a Compute Budget," a Presen...
"Using Deep Learning for Video Event Detection on a Compute Budget," a Presen...Edge AI and Vision Alliance
 
"Optimizing SSD Object Detection for Low-power Devices," a Presentation from ...
"Optimizing SSD Object Detection for Low-power Devices," a Presentation from ..."Optimizing SSD Object Detection for Low-power Devices," a Presentation from ...
"Optimizing SSD Object Detection for Low-power Devices," a Presentation from ...Edge AI and Vision Alliance
 

What's hot (6)

Quantified Social und das Internet der Dinge
Quantified Social und das Internet der DingeQuantified Social und das Internet der Dinge
Quantified Social und das Internet der Dinge
 
Social Media Week 2015 - Quantified Self and the Social Internet of Things
Social Media Week 2015 - Quantified Self and the Social Internet of ThingsSocial Media Week 2015 - Quantified Self and the Social Internet of Things
Social Media Week 2015 - Quantified Self and the Social Internet of Things
 
USING VISION SENSORS FOR INNOVATIVE HCI
USING VISION SENSORS FOR INNOVATIVE HCIUSING VISION SENSORS FOR INNOVATIVE HCI
USING VISION SENSORS FOR INNOVATIVE HCI
 
Future of manufacturing + engineering summit uvs5
Future of manufacturing + engineering summit   uvs5Future of manufacturing + engineering summit   uvs5
Future of manufacturing + engineering summit uvs5
 
"Using Deep Learning for Video Event Detection on a Compute Budget," a Presen...
"Using Deep Learning for Video Event Detection on a Compute Budget," a Presen..."Using Deep Learning for Video Event Detection on a Compute Budget," a Presen...
"Using Deep Learning for Video Event Detection on a Compute Budget," a Presen...
 
"Optimizing SSD Object Detection for Low-power Devices," a Presentation from ...
"Optimizing SSD Object Detection for Low-power Devices," a Presentation from ..."Optimizing SSD Object Detection for Low-power Devices," a Presentation from ...
"Optimizing SSD Object Detection for Low-power Devices," a Presentation from ...
 

Similar to Type-safe DSLs

C:\Alon Tech\New Tech\Embedded Conf Tlv\Prez\Sightsys Embedded Day
C:\Alon Tech\New Tech\Embedded Conf Tlv\Prez\Sightsys Embedded DayC:\Alon Tech\New Tech\Embedded Conf Tlv\Prez\Sightsys Embedded Day
C:\Alon Tech\New Tech\Embedded Conf Tlv\Prez\Sightsys Embedded DayArik Weinstein
 
The Eclipse M2M IWG and Standards for the Internet of Things
The Eclipse M2M IWG and Standards for the Internet of ThingsThe Eclipse M2M IWG and Standards for the Internet of Things
The Eclipse M2M IWG and Standards for the Internet of ThingsWerner Keil
 
Building Domain-Specific Decision Models
Building Domain-Specific Decision ModelsBuilding Domain-Specific Decision Models
Building Domain-Specific Decision ModelsJacob Feldman
 
Decision CAMP 2014 - Jacob Feldman - Building Domain-Specific Decision Models
Decision CAMP 2014 - Jacob Feldman - Building Domain-Specific Decision ModelsDecision CAMP 2014 - Jacob Feldman - Building Domain-Specific Decision Models
Decision CAMP 2014 - Jacob Feldman - Building Domain-Specific Decision ModelsDecision CAMP
 
DDS Advanced Tutorial - OMG June 2013 Berlin Meeting
DDS Advanced Tutorial - OMG June 2013 Berlin MeetingDDS Advanced Tutorial - OMG June 2013 Berlin Meeting
DDS Advanced Tutorial - OMG June 2013 Berlin MeetingJaime Martin Losa
 
DAE Tools 1.8.0 - Introduction
DAE Tools 1.8.0 - IntroductionDAE Tools 1.8.0 - Introduction
DAE Tools 1.8.0 - IntroductionDragan Nikolić
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9google
 
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesCHOOSE
 
Modelica-OpenModelica-slides para aprender.pdf
Modelica-OpenModelica-slides para aprender.pdfModelica-OpenModelica-slides para aprender.pdf
Modelica-OpenModelica-slides para aprender.pdfCarlos Paredes
 
Integrating DDS into AXCIOMA, the component approach
Integrating DDS into AXCIOMA, the component approachIntegrating DDS into AXCIOMA, the component approach
Integrating DDS into AXCIOMA, the component approachRemedy IT
 
Integrating DDS into AXCIOMA - The Component Approach
Integrating DDS into AXCIOMA - The Component ApproachIntegrating DDS into AXCIOMA - The Component Approach
Integrating DDS into AXCIOMA - The Component ApproachReal-Time Innovations (RTI)
 
Eclipse Modeling Framework
Eclipse Modeling FrameworkEclipse Modeling Framework
Eclipse Modeling FrameworkAjay K
 
CocomoModels MGK .ppt
CocomoModels MGK .pptCocomoModels MGK .ppt
CocomoModels MGK .pptssuser3d1dad3
 
Model Driven, Component Based Development for CBDDS and IDL to C++11
Model Driven, Component Based Development for CBDDS and IDL to C++11Model Driven, Component Based Development for CBDDS and IDL to C++11
Model Driven, Component Based Development for CBDDS and IDL to C++11Remedy IT
 
Track A-Compilation guiding and adjusting - IBM
Track A-Compilation guiding and adjusting - IBMTrack A-Compilation guiding and adjusting - IBM
Track A-Compilation guiding and adjusting - IBMchiportal
 
Integrating DDS into AXCIOMA, the component approach
Integrating DDS into AXCIOMA, the component approachIntegrating DDS into AXCIOMA, the component approach
Integrating DDS into AXCIOMA, the component approachRemedy IT
 
Runtime Environment Of .Net Divya Rathore
Runtime Environment Of .Net Divya RathoreRuntime Environment Of .Net Divya Rathore
Runtime Environment Of .Net Divya RathoreEsha Yadav
 

Similar to Type-safe DSLs (20)

C:\Alon Tech\New Tech\Embedded Conf Tlv\Prez\Sightsys Embedded Day
C:\Alon Tech\New Tech\Embedded Conf Tlv\Prez\Sightsys Embedded DayC:\Alon Tech\New Tech\Embedded Conf Tlv\Prez\Sightsys Embedded Day
C:\Alon Tech\New Tech\Embedded Conf Tlv\Prez\Sightsys Embedded Day
 
The Eclipse M2M IWG and Standards for the Internet of Things
The Eclipse M2M IWG and Standards for the Internet of ThingsThe Eclipse M2M IWG and Standards for the Internet of Things
The Eclipse M2M IWG and Standards for the Internet of Things
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
Building Domain-Specific Decision Models
Building Domain-Specific Decision ModelsBuilding Domain-Specific Decision Models
Building Domain-Specific Decision Models
 
Decision CAMP 2014 - Jacob Feldman - Building Domain-Specific Decision Models
Decision CAMP 2014 - Jacob Feldman - Building Domain-Specific Decision ModelsDecision CAMP 2014 - Jacob Feldman - Building Domain-Specific Decision Models
Decision CAMP 2014 - Jacob Feldman - Building Domain-Specific Decision Models
 
C# in depth
C# in depthC# in depth
C# in depth
 
DDS Advanced Tutorial - OMG June 2013 Berlin Meeting
DDS Advanced Tutorial - OMG June 2013 Berlin MeetingDDS Advanced Tutorial - OMG June 2013 Berlin Meeting
DDS Advanced Tutorial - OMG June 2013 Berlin Meeting
 
Ph.D. Defense
Ph.D. DefensePh.D. Defense
Ph.D. Defense
 
DAE Tools 1.8.0 - Introduction
DAE Tools 1.8.0 - IntroductionDAE Tools 1.8.0 - Introduction
DAE Tools 1.8.0 - Introduction
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9
 
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
 
Modelica-OpenModelica-slides para aprender.pdf
Modelica-OpenModelica-slides para aprender.pdfModelica-OpenModelica-slides para aprender.pdf
Modelica-OpenModelica-slides para aprender.pdf
 
Integrating DDS into AXCIOMA, the component approach
Integrating DDS into AXCIOMA, the component approachIntegrating DDS into AXCIOMA, the component approach
Integrating DDS into AXCIOMA, the component approach
 
Integrating DDS into AXCIOMA - The Component Approach
Integrating DDS into AXCIOMA - The Component ApproachIntegrating DDS into AXCIOMA - The Component Approach
Integrating DDS into AXCIOMA - The Component Approach
 
Eclipse Modeling Framework
Eclipse Modeling FrameworkEclipse Modeling Framework
Eclipse Modeling Framework
 
CocomoModels MGK .ppt
CocomoModels MGK .pptCocomoModels MGK .ppt
CocomoModels MGK .ppt
 
Model Driven, Component Based Development for CBDDS and IDL to C++11
Model Driven, Component Based Development for CBDDS and IDL to C++11Model Driven, Component Based Development for CBDDS and IDL to C++11
Model Driven, Component Based Development for CBDDS and IDL to C++11
 
Track A-Compilation guiding and adjusting - IBM
Track A-Compilation guiding and adjusting - IBMTrack A-Compilation guiding and adjusting - IBM
Track A-Compilation guiding and adjusting - IBM
 
Integrating DDS into AXCIOMA, the component approach
Integrating DDS into AXCIOMA, the component approachIntegrating DDS into AXCIOMA, the component approach
Integrating DDS into AXCIOMA, the component approach
 
Runtime Environment Of .Net Divya Rathore
Runtime Environment Of .Net Divya RathoreRuntime Environment Of .Net Divya Rathore
Runtime Environment Of .Net Divya Rathore
 

More from Werner Keil

Securing eHealth, eGovernment and eBanking with Java - DWX '21
Securing eHealth, eGovernment and eBanking with Java - DWX '21Securing eHealth, eGovernment and eBanking with Java - DWX '21
Securing eHealth, eGovernment and eBanking with Java - DWX '21Werner Keil
 
OpenDDR and Jakarta MVC - JavaLand 2021
OpenDDR and Jakarta MVC - JavaLand 2021OpenDDR and Jakarta MVC - JavaLand 2021
OpenDDR and Jakarta MVC - JavaLand 2021Werner Keil
 
How JSR 385 could have Saved the Mars Climate Orbiter - Zurich IoT Day 2021
How JSR 385 could have Saved the Mars Climate Orbiter - Zurich IoT Day 2021How JSR 385 could have Saved the Mars Climate Orbiter - Zurich IoT Day 2021
How JSR 385 could have Saved the Mars Climate Orbiter - Zurich IoT Day 2021Werner Keil
 
OpenDDR and Jakarta MVC - Java2Days 2020 Virtual
OpenDDR and Jakarta MVC - Java2Days 2020 VirtualOpenDDR and Jakarta MVC - Java2Days 2020 Virtual
OpenDDR and Jakarta MVC - Java2Days 2020 VirtualWerner Keil
 
NoSQL Endgame - Java2Days 2020 Virtual
NoSQL Endgame - Java2Days 2020 VirtualNoSQL Endgame - Java2Days 2020 Virtual
NoSQL Endgame - Java2Days 2020 VirtualWerner Keil
 
JCON 2020: Mobile Java Web Applications with MVC and OpenDDR
JCON 2020: Mobile Java Web Applications with MVC and OpenDDRJCON 2020: Mobile Java Web Applications with MVC and OpenDDR
JCON 2020: Mobile Java Web Applications with MVC and OpenDDRWerner Keil
 
How JSR 385 could have Saved the Mars Climate Orbiter - JFokus 2020
How JSR 385 could have Saved the Mars Climate Orbiter - JFokus 2020How JSR 385 could have Saved the Mars Climate Orbiter - JFokus 2020
How JSR 385 could have Saved the Mars Climate Orbiter - JFokus 2020Werner Keil
 
Money, Money, Money, can be funny with JSR 354 (Devoxx BE)
Money, Money, Money, can be funny with JSR 354 (Devoxx BE)Money, Money, Money, can be funny with JSR 354 (Devoxx BE)
Money, Money, Money, can be funny with JSR 354 (Devoxx BE)Werner Keil
 
Money, Money, Money, can be funny with JSR 354 (DWX 2019)
Money, Money, Money, can be funny with JSR 354 (DWX 2019)Money, Money, Money, can be funny with JSR 354 (DWX 2019)
Money, Money, Money, can be funny with JSR 354 (DWX 2019)Werner Keil
 
NoSQL: The first New Jakarta EE Specification (DWX 2019)
NoSQL: The first New Jakarta EE Specification (DWX 2019)NoSQL: The first New Jakarta EE Specification (DWX 2019)
NoSQL: The first New Jakarta EE Specification (DWX 2019)Werner Keil
 
How JSR 385 could have Saved the Mars Climate Orbiter - Adopt-a-JSR Day
How JSR 385 could have Saved the Mars Climate Orbiter - Adopt-a-JSR DayHow JSR 385 could have Saved the Mars Climate Orbiter - Adopt-a-JSR Day
How JSR 385 could have Saved the Mars Climate Orbiter - Adopt-a-JSR DayWerner Keil
 
JNoSQL: The Definitive Solution for Java and NoSQL Databases
JNoSQL: The Definitive Solution for Java and NoSQL DatabasesJNoSQL: The Definitive Solution for Java and NoSQL Databases
JNoSQL: The Definitive Solution for Java and NoSQL DatabasesWerner Keil
 
Eclipse JNoSQL: The Definitive Solution for Java and NoSQL Databases
Eclipse JNoSQL: The Definitive Solution for Java and NoSQL DatabasesEclipse JNoSQL: The Definitive Solution for Java and NoSQL Databases
Eclipse JNoSQL: The Definitive Solution for Java and NoSQL DatabasesWerner Keil
 
Physikal - Using Kotlin for Clean Energy - KUG Munich
Physikal - Using Kotlin for Clean Energy - KUG MunichPhysikal - Using Kotlin for Clean Energy - KUG Munich
Physikal - Using Kotlin for Clean Energy - KUG MunichWerner Keil
 
Physikal - JSR 363 and Kotlin for Clean Energy - Java2Days 2017
Physikal - JSR 363 and Kotlin for Clean Energy - Java2Days 2017Physikal - JSR 363 and Kotlin for Clean Energy - Java2Days 2017
Physikal - JSR 363 and Kotlin for Clean Energy - Java2Days 2017Werner Keil
 
Performance Monitoring for the Cloud - Java2Days 2017
Performance Monitoring for the Cloud - Java2Days 2017Performance Monitoring for the Cloud - Java2Days 2017
Performance Monitoring for the Cloud - Java2Days 2017Werner Keil
 
Eclipse Science F2F 2016 - JSR 363
Eclipse Science F2F 2016 - JSR 363Eclipse Science F2F 2016 - JSR 363
Eclipse Science F2F 2016 - JSR 363Werner Keil
 
Java2Days - Security for JavaEE and the Cloud
Java2Days - Security for JavaEE and the CloudJava2Days - Security for JavaEE and the Cloud
Java2Days - Security for JavaEE and the CloudWerner Keil
 
Apache DeviceMap - Web-Dev-BBQ Stuttgart
Apache DeviceMap - Web-Dev-BBQ StuttgartApache DeviceMap - Web-Dev-BBQ Stuttgart
Apache DeviceMap - Web-Dev-BBQ StuttgartWerner Keil
 
The First IoT JSR: Units of Measurement - JUG Berlin-Brandenburg
The First IoT JSR: Units of Measurement - JUG Berlin-BrandenburgThe First IoT JSR: Units of Measurement - JUG Berlin-Brandenburg
The First IoT JSR: Units of Measurement - JUG Berlin-BrandenburgWerner Keil
 

More from Werner Keil (20)

Securing eHealth, eGovernment and eBanking with Java - DWX '21
Securing eHealth, eGovernment and eBanking with Java - DWX '21Securing eHealth, eGovernment and eBanking with Java - DWX '21
Securing eHealth, eGovernment and eBanking with Java - DWX '21
 
OpenDDR and Jakarta MVC - JavaLand 2021
OpenDDR and Jakarta MVC - JavaLand 2021OpenDDR and Jakarta MVC - JavaLand 2021
OpenDDR and Jakarta MVC - JavaLand 2021
 
How JSR 385 could have Saved the Mars Climate Orbiter - Zurich IoT Day 2021
How JSR 385 could have Saved the Mars Climate Orbiter - Zurich IoT Day 2021How JSR 385 could have Saved the Mars Climate Orbiter - Zurich IoT Day 2021
How JSR 385 could have Saved the Mars Climate Orbiter - Zurich IoT Day 2021
 
OpenDDR and Jakarta MVC - Java2Days 2020 Virtual
OpenDDR and Jakarta MVC - Java2Days 2020 VirtualOpenDDR and Jakarta MVC - Java2Days 2020 Virtual
OpenDDR and Jakarta MVC - Java2Days 2020 Virtual
 
NoSQL Endgame - Java2Days 2020 Virtual
NoSQL Endgame - Java2Days 2020 VirtualNoSQL Endgame - Java2Days 2020 Virtual
NoSQL Endgame - Java2Days 2020 Virtual
 
JCON 2020: Mobile Java Web Applications with MVC and OpenDDR
JCON 2020: Mobile Java Web Applications with MVC and OpenDDRJCON 2020: Mobile Java Web Applications with MVC and OpenDDR
JCON 2020: Mobile Java Web Applications with MVC and OpenDDR
 
How JSR 385 could have Saved the Mars Climate Orbiter - JFokus 2020
How JSR 385 could have Saved the Mars Climate Orbiter - JFokus 2020How JSR 385 could have Saved the Mars Climate Orbiter - JFokus 2020
How JSR 385 could have Saved the Mars Climate Orbiter - JFokus 2020
 
Money, Money, Money, can be funny with JSR 354 (Devoxx BE)
Money, Money, Money, can be funny with JSR 354 (Devoxx BE)Money, Money, Money, can be funny with JSR 354 (Devoxx BE)
Money, Money, Money, can be funny with JSR 354 (Devoxx BE)
 
Money, Money, Money, can be funny with JSR 354 (DWX 2019)
Money, Money, Money, can be funny with JSR 354 (DWX 2019)Money, Money, Money, can be funny with JSR 354 (DWX 2019)
Money, Money, Money, can be funny with JSR 354 (DWX 2019)
 
NoSQL: The first New Jakarta EE Specification (DWX 2019)
NoSQL: The first New Jakarta EE Specification (DWX 2019)NoSQL: The first New Jakarta EE Specification (DWX 2019)
NoSQL: The first New Jakarta EE Specification (DWX 2019)
 
How JSR 385 could have Saved the Mars Climate Orbiter - Adopt-a-JSR Day
How JSR 385 could have Saved the Mars Climate Orbiter - Adopt-a-JSR DayHow JSR 385 could have Saved the Mars Climate Orbiter - Adopt-a-JSR Day
How JSR 385 could have Saved the Mars Climate Orbiter - Adopt-a-JSR Day
 
JNoSQL: The Definitive Solution for Java and NoSQL Databases
JNoSQL: The Definitive Solution for Java and NoSQL DatabasesJNoSQL: The Definitive Solution for Java and NoSQL Databases
JNoSQL: The Definitive Solution for Java and NoSQL Databases
 
Eclipse JNoSQL: The Definitive Solution for Java and NoSQL Databases
Eclipse JNoSQL: The Definitive Solution for Java and NoSQL DatabasesEclipse JNoSQL: The Definitive Solution for Java and NoSQL Databases
Eclipse JNoSQL: The Definitive Solution for Java and NoSQL Databases
 
Physikal - Using Kotlin for Clean Energy - KUG Munich
Physikal - Using Kotlin for Clean Energy - KUG MunichPhysikal - Using Kotlin for Clean Energy - KUG Munich
Physikal - Using Kotlin for Clean Energy - KUG Munich
 
Physikal - JSR 363 and Kotlin for Clean Energy - Java2Days 2017
Physikal - JSR 363 and Kotlin for Clean Energy - Java2Days 2017Physikal - JSR 363 and Kotlin for Clean Energy - Java2Days 2017
Physikal - JSR 363 and Kotlin for Clean Energy - Java2Days 2017
 
Performance Monitoring for the Cloud - Java2Days 2017
Performance Monitoring for the Cloud - Java2Days 2017Performance Monitoring for the Cloud - Java2Days 2017
Performance Monitoring for the Cloud - Java2Days 2017
 
Eclipse Science F2F 2016 - JSR 363
Eclipse Science F2F 2016 - JSR 363Eclipse Science F2F 2016 - JSR 363
Eclipse Science F2F 2016 - JSR 363
 
Java2Days - Security for JavaEE and the Cloud
Java2Days - Security for JavaEE and the CloudJava2Days - Security for JavaEE and the Cloud
Java2Days - Security for JavaEE and the Cloud
 
Apache DeviceMap - Web-Dev-BBQ Stuttgart
Apache DeviceMap - Web-Dev-BBQ StuttgartApache DeviceMap - Web-Dev-BBQ Stuttgart
Apache DeviceMap - Web-Dev-BBQ Stuttgart
 
The First IoT JSR: Units of Measurement - JUG Berlin-Brandenburg
The First IoT JSR: Units of Measurement - JUG Berlin-BrandenburgThe First IoT JSR: Units of Measurement - JUG Berlin-Brandenburg
The First IoT JSR: Units of Measurement - JUG Berlin-Brandenburg
 

Recently uploaded

Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 

Recently uploaded (20)

Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 

Type-safe DSLs

  • 1. Type-safe DSLs Using Xtext/TS, Xtend, Groovy and other languages Werner Keil Eclipse DemoCamp Hamburg 14th June 2012
  • 2. Our Goal AVOIDING ARITHMETIC OR TYPE ERRORS IN A DSL 2 © 2007-2012 Creative Arts & Technologies
  • 3. Overview • Introduction • What is a DSL? • Internal and External DSLS • Type-Safety • Units and Healthcare • Unit-API, UOMo • UCUM, HL7, Groovy used by Healthcare • Other Languages • Jython/WLST • Xtext/Xbase/Xtend • Scala, Fantom, F# • Demo • Q&A 3 © 2007-2012 Creative Arts & Technologies
  • 4. Who am I? Werner Keil • Consultant – Coach • Creative Cosmopolitan • Open Source Evangelist • Software Architect • Java Godfather • … Twitter @wernerkeil 4 © 2007-2012 Creative Arts & Technologies
  • 5. What is a DSL? • A DSL is a computer language (specification, modeling, programming) tailored to a particular domain. But, what is a domain? • DSL examples: SQL, CSS, Sawzall (Google) • Gains in expressiveness and ease of use (the future could be end-user programming) • Gains in productivity • Reduced maintenance costs 5 © 2007-2012 Creative Arts & Technologies
  • 6. What is a Domain? Real-Time Business Systems Systems Requirements Specification Aircraft Patient Insurance control Management Management Implementation systems Systems Systems Deployment 6 © 2007-2012 Creative Arts & Technologies
  • 7. Internal Domain Specific Languages • These are languages built using the syntactic elements of the underlying language • In the case of Java, building a DSL using Java classes and methods • With other JVM-based languages, that’s usually similar, Java code generated in many cases 7 © 2007-2012 Creative Arts & Technologies
  • 8. External Domain Specific Languages • External DSLs • Written in a different language than the main (host) language of the application • Transformed into it using some form of compiler or interpreter • May include • XML configuration files • Plain text configuration files • Full-blown languages 8 © 2007-2012 Creative Arts & Technologies
  • 9. Type-Safety • Java does not have strongly typed primitive types (like e.g. Ada language). • For performance reasons most developer prefer primitive types over objects in their interface. • Primitives type arguments often lead to name clashes (methods with the same signature) 9 © 2007-2012 Creative Arts & Technologies
  • 10. What do these disasters have in common? • Patriot Missile The cause was an inaccurate calculation of the time since boot due to a computer arithmetic error. • Ariane 5 Explosion The floating point number which a value was converted from had a value greater than what would be represented by a 16 bit signed integer. 10 © 2007-2012 Creative Arts & Technologies
  • 11. What do these disasters have in common? • Gimli Glider (near disaster) Fuel loading was miscalculated through misunderstanding of the recently adopted Metric System, replacing the Imperial System • Mars Orbiter Preliminary findings indicate that one team used English units (e.g. inches, feet and pounds) while the other used metric units for a key spacecraft operation. • NASA lost a $125 million Mars orbiter because a Lockheed Martin engineering team used English units of measurement while the agency's team used the more conventional metric system for a key spacecraft operation • This also underlines the added risk when 3 rd party contractors are involved or projects are developed Offshore 11 © 2007-2012 Creative Arts & Technologies
  • 12. Unit Tests wouldn‘t find these… Despite their name • All previous example illustrate three categories of errors difficult to find through Unit Testing: • Interface Errors (e.g. millisecond/second, radian/degree, meters/feet). • Arithmetic Errors (e.g. overflow). • Conversion Errors. 17 © 2007-2012 Creative Arts & Technologies
  • 13. SQL Example with Errors StringBuilder sql = new StringBuilder(); sql.append("SELECT o.sum,(SELECT first_name,last_name"); sql.append(" FROM person p"); sql.append(" WHERE o.person_id=p.id) AS client"); sql.append(" FROM order o"); sql.append("WHERE o.id = "+orderId); sql.append(" AND o.status_code IN (?,?)"); PreparedStatement stmt = conn.prepareStatement(sql.toString()); stmt.setString(1, "PAID"); //... 19 © 2007-2012 Creative Arts & Technologies
  • 14. Typesafe SQL Example Person p = new Person(); List<Tuple<String, Integer, Date>> rows = new QueryBuilder(datasource) .from(p) .where(gt(p.height, 170)) .select(p.name, p.height, p.birthday) .list(); for (Tuple<String, Integer, Date> row : rows) { String name = row.v1; Integer height = row.v2; Date birthday = row.v3; System.out.println( name + " " + height + " " + birthday); } 20 © 2007-2012 Creative Arts & Technologies
  • 15. Unit-API | Operations Results with Same Dimension Different Dimension Binary Operations Binary Operations add(double) or (long) root(int) multiply(double) or (long) power(int) divide(double) or (long) multiply(Unit) compound(Unit) divide(Unit) Unary Operations inverse()
  • 16. UOMo UCUM Unified Code for Units of Measure The Unified Code for Units of Measure is inspired by and heavily based on • ISO 2955-1983 • ANSI X3.50-1986 • HL7's extensions called ISO+ 25 © 2007-2012 Creative Arts & Technologies
  • 17. HL7 DSL def mySegment = ... // assignment to another NK1 segment instance def group = message.PATIENT_RESULT(0).PATIENT group.NK1(0) = 'abc' // syntax error! msg1.NK1(0) = mySegment // syntax error! msg1.NK1(0).from(mySegment) // works! def nk1 = message.PATIENT_RESULT(0).PATIENT.NK1(0) def otherNk1 = message.PATIENT_RESULT(0).PATIENT.NK1(0) nk1[4] = otherNk1[4] // copy address nk1[4][4] = otherNk1[4][4] // copy state or province only nk1[4][4].from(otherNk1[4][4])// equivalent nk1[4][4] = 'NY' // set state or province directly 26 © 2007-2012 Creative Arts & Technologies
  • 18. Healthcare DSL with Groovy DEMO
  • 19. Jython /** * Java calculator class that contains two simple methods */ public class Calculator { public Calculator(){ } public double calculateTip(double cost, double tipPercentage) { return cost * tipPercentage; } public double calculateTax(double cost, double taxPercentage) { return cost * taxPercentage; } } 28 © 2007-2012 Creative Arts & Technologies
  • 20. Jython (2) import Calculator from java.lang import Math class JythonCalc(Calculator): def __init__(self): pass def calculateTotal(self, cost, tip, tax): return cost + self.calculateTip(tip) + self.calculateTax(tax) if __name__ == "__main__": calc = JythonCalc() cost = 23.75 tip = .15 tax = .07 print "Starting Cost: ", cost print "Tip Percentage: ", tip print "Tax Percentage: ", tax print Math.round(calc.calculateTotal(cost, tip, tax)) 29 © 2007-2012 Creative Arts & Technologies
  • 21. Jython (3) Result Starting Cost: 23.75 Tip Percentage: 0.15 Tax Percentage: 0.07 29 30 © 2007-2012 Creative Arts & Technologies
  • 23. Scala, Fantom, F# • Scala • Functional programming language. Type-safe, as the company driving it was called. • Very popular for DSLs • Fantom • Functional programming language • Units of Measurement support built in. • Runs on both JVM and CLR • F# • Functional programming language • Units of Measurement support built in. 33 © 2007-2012 Creative Arts & Technologies
  • 24. Scala and Fantom Examples DEMO
  • 25. Links Eclipse – Project UOMo http://www.eclipse.org/uomo/ Units of Measurement API http://www.unitsofmeasurement.org UCUM http://www.unitsofmeasure.org
  • 26. Links (2) OpenHealth Project http://www.openhealth.org Groovy DSL Example http://groovy.dzone.com/news/domain- specific-language-unit- Jython http://www.jython.org
  • 27. Links (3) Xtext http://www.eclipse.org/xtext Scala DSLs http://www.scala-lang.org/node/1403 Fantom http://fantom.org/
  • 29. Contact werner@catmedia.us or uomo@catmedia.us Twitter: @wernerkeil Hashtag #EclipseUOMo