declarative software developmentsoftlang/140909... · 2014-09-08 · declarative software...

42
© 2014 Software Languages Team, University of Koblenz-Landau Declarative Software Development Distilled Tutorial Ralf Lämmel Software Languages Team, University of Koblenz Landau Joint work with Andrei Varanovich, Martin Leinberger, Thomas Schmorleiz, Jean-Marie Favre 1

Upload: others

Post on 21-Jun-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Declarative Software Development!Distilled Tutorial!

!Ralf Lämmel!

Software Languages Team, University of Koblenz Landau!Joint work with Andrei Varanovich, Martin Leinberger, Thomas Schmorleiz, Jean-Marie Favre

1

Page 2: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Declarative Software Development? How the title emerged …

• Ralf: Here is my title: „Towards an ontology for software development“.

• Olivier: May I suggest the title „Towards a Declarative Ontology for Software Development“?

• Ralf: Any ontology is declarative. What about this title: „Declarative knowledge about software development“?

• Olivier: „Declarative Software Development“ would come across as more radical, possibly even novel.

• Ralf: Thanks for radicalizing me. I go with your proposal.

2

Page 3: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

What’s NOT meant by !declarative software development …

• (Exclusive) use of declarative PLs in development!

• Use of formal methods instead!

• Use of MDE and model transformations instead

3

Page 4: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Linked Software Data

Declarative software development: The focus is on understanding

Software systems

apply!to

apply!to

refer!to

Software analysis

uses(S,’JUnit’) ⇐ !! imports(S, ’org.junit’).

refer!to

Technology models

An XML schema

An object model

map !to

apply!to

Software ontologyThing

Language Technology Concept

4

Page 5: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Linked Software Data with 101explorer and 101triples

Declarative software development: The focus is on understanding

Chrestomathy 101

apply!to

apply!to

refer!to

The 101worker infrastructure

uses(S,’JUnit’) ⇐ !! imports(S, ’org.junit’).

refer!to

The MegaL language

An XML schema

An object model

map !to

apply!to

The SoLaSoTe ontologyThing

Language Technology Concept

5

Page 6: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Why is this important?

EMF

SQL

TENEO

Java

XSD

DOM

Antlr

OWL

UML

XMI

Ecore

SQL DDL

XLSTSaxon

Hibernate

Awk

Json

Yacc

JAXP

RestOWL

RDF

ATOM

SparQLXSLT

DTD

BNF

XSD

OCL

Prolog

grep

MOF

OMG

QVT

jDOMRose

Protegé

XQuery

ODM

XMLSpy

JPA

JAXB

JDBC

ODBC

MySQLArgoUML

Jena

Jena

Dragan

TXL

VLDB

EMF.gen

ORACLE

TCS

XText

Teneo

Jersey

GWT

Sesame

Stratego

XPATH

JavaBeans

UTF8

ASCII

RDFa

RDF(S)

RDFS

CFG

LALR

ER

xerces

xalan

saxonsax

sed

XSD

JMI JMF

SBVR

… because of the

technology plethora

6

Page 7: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

The software chrestomathy 101companies

A quick intro

Software systems

7

Page 8: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

The 101companies projectCompany X:

Swing + JDBC !!!!

Company Y: SWT + Hibernate

!!!!

Company Z: GWT + MongoDB

!!!!

... !!!!

Different implementations of the same

system varying languages, technologies,

and concepts.

!

For what it matters, it’s an HRMS:

a human resources management system.

8

Page 9: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Data & functionality of 101’s system

• Total: Sum up all salaries

• Increase: Increase salaries of all employees

• Cut: Cut all salaries in half

• Persistence: Persist companies

• Editing: GUI support for editing companies

• …

9

Page 10: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

A Prolog-based implementation10

Scrap Your Boilerplate—Prologically!

PPDP 2009

Page 11: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

101’s features

11

Page 12: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

101’s implementations

12

Page 13: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

• 101repo! ! ! GitHub-based source code repo!

• 101wiki! ! ! Semantic wiki-based documentation!

• 101worker! ! Infrastructure for automated analysis!

• 101explorer!! Linked Data explorer!

• 101triples! ! Linked Data SPARQL endpoint!

• SoLaSoTe Underlying ontology

• MegaL Language for technology models

The 101companies project13

Page 14: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

The software ontology SoLaSoTe

A quick intro

Software ontologyThing

Language Technology Concept

14

Page 15: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Types of SoLaSoTe’s individuals15

Page 16: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

For instance: software languages16

Page 17: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

For instance: software technologies17

Page 18: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

For instance: software concepts18

Page 19: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

A SPARQL query sorting software concepts by popularity

19

Thus, the realization of SoLaSoTe depends on RDF, RDFS (OWL), and SPARQL.

Page 20: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Technology modeling with MegaL

A quick intro

Technology models

An XML schema

An object model

map !to

20

Page 21: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

21

A classic „technology model“ for bootstrapping a compiler

http://en.wikipedia.org/wiki/Tombstone_diagram

Page 22: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

22

A general notion of technology model

• Technology models are „ER models“.

• Entities of interest ‣ Software technologies and parts thereof, e.g., Hibernate ‣ Software languages, e.g., SQL ‣ Software artifacts, e.g., O/R mapping file ‣ Software concepts, e.g., persistence ‣ ...

• Relationships of interest ‣ Conformance ‣ Transformation ‣ ...

Page 23: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

23

A technology model for JAXB(XML-data binding of the Java platform)

Part 1: Technology break-down and concepts

Page 24: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

24

A technology model for JAXB(XML-data binding of the Java platform)

Part 2: Type-level mapping

Page 25: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

25

A technology model for JAXB(XML-data binding of the Java platform)

Part 3: Instance-level

mapping

Page 26: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

26

A technology model for JAXB(XML-data binding of the Java platform)

Part 4: Conformance

Page 27: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Software analysis with 101worker (incl. 101meta)

A quick intro

Software analysis

imports(S,’org.junit’)!! ⇐ uses(S, ’JUnit’)

27

Page 28: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

101meta — a rule-based language for metadata inference

uses(C, lang:Haskell) ⇐ !! contrib(C), !! filePartOf(F, C),!! suffix(F, ’.hs’).

implements(C, feature:Total) ⇐ !! contrib(C), !! filePartOf(F, C),!! tokenPartOf(’total’, F).

uses(C, tech:JUnit) ⇐ !! contrib(C), !! filePartOf(F, C),!! imports(F, ’org.junit’).

28

Page 29: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Comparison of feature implementations across languages, technologies, and styles

29

Involved analyses:!• NCLOC metrics • Feature detection • Comparison of detected and declared features

Haskell „wins“

Page 30: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Linked Software Data with 101explorer and 101triples

A quick intro

30

Page 31: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Linked software dataUse and enrich Linked Data principles:!

• Use URIs as names for things, e.g., languages. !

• Make URIs HTTP resolvable.!

• Provide useful info, e.g., schemas or source code.!

• Provide data for humans & software: HTML, JSON, RDF.!

• Include links to other resources, e.g., GitHub or 101wiki.

31

Page 32: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Exploration of software dataA video going through these stages:

• 101’s contribution haskellStarter on 101wiki

• Ditto’s contribution source code on 101repo!

• Various related resources on 101explorer!

• The Haskell entity on101triples!

• An illustrative query on SPARQL endpoint

32

Demo

https://www.youtube.com/watch?v=0MkzWMPp1lI

Page 33: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

The software ontology SoLaSoTe

Deep(er) !dive

33

Page 34: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

SoLaToSe aspects

• Classification (instanceOf, isA)!

• Relationships (uses, supports, …)!

• Containers (themes, vocabularies, …)

• Systems (101)

• Other resources (sameAs, …)

• Validation of the ontology

34

Page 35: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Classification35

trueIs ‚Java‘ a language?

What are the supertypes of ‚Java‘?

What are popular classifiers?

Page 36: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Predicates for relationships 36

For example: feature:Hierarchical_company

moreComplexThan feature:Flat_company

For example: tech:ghc partOf

tech:Haskell_platform

For example: tech:Ruby_on_Rails

supports concept:REST

Page 37: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Predicates for relationships 37

Page 38: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Query: Arrange lecture in a course38

Arrange scripts

(lectures) in an order

that respect the lecture

dependencies.

Page 39: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

RDFS’ inference vs. SPARQL’s validation 39

onto:contribUsesLang rdfs:type rdfs:Property ; rdfs:subPropertyOf onto:uses ; rdfs:comment "Use of languages by contributions" ; rdfs:domain onto:Contribution; rdfs:range onto:Language .

RDFS

Semantics: if a resource is the subject of

‚contribUsesLang’, then it is of type `Contribution’.

TODO (Martin): Complete sandbox upload on 101worker.

Query uniqueType.sparql

SELECT ?entity ?t1 ?t2 {?entity a ?t1 .?entity a ?t2 .FILTER (?t1 != ?t2 && ?t1 != onto:Entity && ?t2 != onto:Entity) .?t1 rdfs:subClassOf onto:Entity .?t2 rdfs:subClassOf onto:Entity .FILTER NOT EXISTS { ?t1 a onto:Classifier } .FILTER NOT EXISTS { ?t2 a onto:Classifier }

}

Query testDomain.sparql

SELECT ?x {?x onto:contribUsesLang ?y .FILTER NOT EXISTS { ?x sesame:directType onto:Contribution }

}

Query testRange.sparql

SELECT ?y {?x onto:contribUsesLang ?y .FILTER NOT EXISTS { ?y a onto:Language }

}

9 Concluding remarks

TODO (Ralf): Write this section eventually.

References

[1] H. Halpin, P. J. Hayes, and H. S. Thompson. When owl:sameAs isn’t theSame Redux: A preliminary theory of identity and inference on the SemanticWeb. In Workshop on Discovering Meaning On the Go in Large Heteroge-neous Data 2011 (LHD-11), Barcelona, Spain, July 16, 2011, pages 25–30,2011.

31

Semantics: find resources that are subjects of ‚contribUsesLang’ without being of declared type `Contribution’.

SPARQL

Page 40: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

OWL’s consistency vs. SPARQL’s validation40

SPARQL

<owl:AllDisjointClasses><owl:members rdf:parseType="Collection"> <owl:class rdf:about="http://101companies.org/ontology#Language"/> <owl:class rdf:about="http://101companies.org/ontology#Technology"/> <owl:class rdf:about="http://101companies.org/ontology#Concept"/> ...</owl:members></owl:AllDisjointClasses>

OWL

Merely a declaration of a consistency requirement without

standardized reporting semantics

An operational query for entities with more than one entity type

Page 41: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Future research• Community process for ontology evolution!

• Ontology integration with Wikipedia et al.!

• Help developers (akin to StackOverflow)!

• Programming models for Linked Data!

• Validation / mapping for ontologies!

• More advanced reasoning than in SoLaSoTe

41

Page 42: Declarative Software Developmentsoftlang/140909... · 2014-09-08 · Declarative Software Development! Distilled Tutorial!! Ralf Lämmel! Software Languages Team, University of Koblenz

© 2014 Software Languages Team, University of Koblenz-Landau

Further reading• R. Lämmel. Software chrestomathies. Sci. Comput. Program., 2013 • J.-M. Favre, R. Lämmel, T. Schmorleiz, and A. Varanovich.

101companies: A Community Project on Software Technologies and Software Languages. TOOLS 2012.

• J.-M. Favre, R. Lämmel, and A. Varanovich. Modeling the Linguistic Architecture of Software Products. MODELS 2012.

• R. Lämmel and A. Varanovich. Interpretation of Linguistic Architecture. ECMFA 2014.

• J.-M. Favre, R. Lämmel, M. Leinberger, T. Schmorleiz, and A. Vara- novich. Linking Documentation and Source Code in a Software Chrestomathy. WCRE 2012.

• R. Lämmel, M. Leinberger, T. Schmorleiz, and A. Varanovich. Comparison of feature implementations across languages, technologies, and styles. CSMR-WCRE 2014.

• M. Leinberger. Enhancement of a software chrestomathy for open linked data. MSc Thesis. Universität Koblenz-Landau. 2013.

See the PPDP 2014 paper.

42

End of talkDrop me an email, if you like to play with the triples.!

Looking for project partners!