xtext project and phds in gemany

54
T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 1 Xtext: Eclipse-based framework for defining Domain-Specific Languages (DSLs) Thomas Baar [email protected] (temporary *) NSU Tech Talk; Akademgorodok, 2015-11-24 Guest Lecturer at: Home University: * My stay at Novosibirsk State University is supported by DAAD (German Academic Exchange Service).

Upload: tech-talks-nsu

Post on 19-Jan-2017

206 views

Category:

Software


6 download

TRANSCRIPT

Page 1: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 1

Xtext: Eclipse-based framework for defining

Domain-Specific Languages (DSLs)

Thomas [email protected] (temporary *)

NSU Tech Talk; Akademgorodok, 2015-11-24

Guest Lecturer at:

Home University:

* My stay at Novosibirsk State University is supported by DAAD (German Academic Exchange Service).

Page 2: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 2

Domain-Specific Language (DSL)

A DSL is a notation for expressing observations, facts, algorithms

in an elegant way. The notation can be

- textual

- graphical

- table-oriented

or a mixture of the above.

Page 3: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 3

Domain-Specific Language (DSL)

Compared to general-purpose modeling languages (e.g. UML) or

programming languages (e.g. Java), DSLs have usually a (much)

less complex syntax while being expressive enough for the

domains they target!

Page 4: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 4

Domain-Specific Language (DSL)

Compared to general-purpose modeling languages (e.g. UML) or

programming languages (e.g. Java), DSLs have usually a (much)

less complex syntax while being expressive enough for the

domains they target!

Domain-specific models/programs are typically less complex

than models/programs written in a general purpose language.

Thus, they are easier to understand and to maintain.

Page 5: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 5

DSL ExamplesDomain

Typesetting

Language

Latex

Source: Britannica kids. kid.eb.com

Page 6: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 6

DSL ExamplesDomain

Automatic Software Build

Language

make

Page 7: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 7

DSL ExamplesDomain

Chemistry

Language

Mendeleev's periodic

system of chemical

elements

Page 8: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 8

DSL ExamplesDomain

Process Description

Language

Harel's statecharts

Page 9: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 9

- Что такое?

• Eclipse-framework for defining textual DSLs

- actually, Xtext is the heart of Eclipse bundle "Eclipse for Java

and DSL developers"

Page 10: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 10

- Что такое?

• Eclipse-framework for defining textual DSLs

- actually, Xtext is the heart of Eclipse bundle "Eclipse for Java

and DSL developers"

• Open source, but professionally developed and maintained by

start-up company Itemis (Kiel, Germany)

- matured code, release 2.9 expected early Dec 2015

- nice documentation/tutorials

- active forum, fast bug-fixes

Page 11: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 11

- Что такое?

• Eclipse-framework for defining textual DSLs

- actually, Xtext is the heart of Eclipse bundle "Eclipse for Java

and DSL developers"

• Open source, but professionally developed and maintained by

start-up company Itemis (Kiel, Germany)

- matured code, release 2.9 expected early Dec 2015

- nice documentation/tutorials

- active forum, fast bug-fixes

• Very informative website www.eclipse.org/xtext

- short video tutorials explaining each editor feature

- links to what community has implemented using Xtext

Page 12: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 12

Xtext: Mission & Workflow

Mission: Make the Definition and Usage of textual DSLs as easy as possible.

Page 13: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 13

Overview on DSL DefinitionDSL-Part Defined in Purpose

Grammar EBNF-inspired Grammar language

specify lexer, parser

Validator Xtend * filter out non-intended input models; trigger error-markers in editor

Scope definitions Xtend resolve cross-references

Editor configurations (Overview pane, content assist/auto-completion, font-selection, tooltips, etc.)

Xtend adjust editor features

Code generator Xtend specify code generator

Tests Xtend execute test cases for lexer, parser, validator, scope provider, editor, eclipse integration, etc.

* Xtend - An extension of Java invented from Xtext-team in order to make typical programming tasks (e.g. AST traversion, code templates) much easier.

Page 14: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 14

More detailed DSL-Definition Workflow

Page 15: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 15

Example Project

Beans

Page 16: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 16

A Simple Example: Beans-- Create an Xtext Project --

Page 17: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 17

A Simple Example: Beans-- Define the Grammar --

Page 18: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 18

A Simple Example: Beans-- Define the Grammar --

Header

Start Rule

Feature in generatedEMF class

Cross-reference

Keyword

Optional Occurence

Page 19: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 19

Xtext is build on top of the parser generator ANTLR. For the above grammar,

much longer input files for ANTLR have been generated (299 LOC, 24 LOC).

A Simple Example: Beans-- Define the Grammar --

Header

Start Rule

Feature in generatedEMF class

Cross-reference

Keyword

Optional Occurence

The formalism for defining a grammar is a DSL! This DSL has been implemented by Xtext itself ;-)

Page 20: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 20

A Simple Example: Beans-- Testing the Parser using JUnit --

Pre-definedhelper classes

String templates(enclosed by ''' )

Extension method(actually definedin ParserHelper andnot in String)

Page 21: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 21

A Simple Example: Beans-- Adding a Validator: Making the syntax more precise --

class BeansDslValidator extends AbstractBeansDslValidator {

public static val INVALID_NAME = 'invalidName'

@Checkdef checkBeannameStartsWithCapital(Bean bean) {

if (!Character.isUpperCase(bean.name.charAt(0))) {error('Name must start with a capital',

BeansDslPackage.Literals.BEAN__NAME, INVALID_NAME)

}}

}

Mark input text as erroneousunder certain circumstances

Page 22: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 22

A Simple Example: Beans-- Testing the Validator using JUnit --

Page 23: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 23

A Simple Example: Beans-- Enjoy the Editor :-) --

Content assist(aka auto-completion)

Grammar error (missing ';')

Validation error (no capital letter)

Page 24: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 24

A Simple Example: Beans-- Specify a Code Generator using Xtend --

class BeansDslGenerator implements IGenerator {override void doGenerate(Resource resource, IFileSystemAccess fsa) {

resource.allContents.toIterable.filter(typeof(Bean)).forEach[fsa.generateFile('''beans/«name».java''', compile)

]}

def compile(Bean bean) {'''public class «bean.name» «IF bean.superType != null»extends «bean.superType.name» «ENDIF»{

«FOR att : bean.attributes»private «att.type.typeToString» «att.name»;«ENDFOR»

«FOR att : bean.attributes»public «att.type.typeToString» get«att.name.toFirstUpper»() {

return «att.name»;}

public void set«att.name.toFirstUpper»(«att.type.typeToString» _arg) {this.«att.name» = _arg;

}«ENDFOR»

}'''}

def typeToString(BasicType type) {if (type.literal.equals("string")) "String" else type}

}

Output written in .java file

Each bean becomes a Java class

Each bean attribute is mapped to Java attribute, getter- and setter-method

Page 25: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 25

A Simple Example: Beans-- Enjoy the Code Generator :-) --

One input file(written in ourDSL)

Location of generatedartifacts

Three output files(written in targetlanguage)

Page 26: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 26

A Simple Example: Beans-- Testing Code Generator using JUnit --

class BeansGeneratorTests {@Rule@Inject public TemporaryFolder temporaryFolder

@Inject extension CompilationTestHelper@Inject extension ReflectExtensions

@Testdef void testTwoCompiledClasses() {

'''bean Person{string name;}bean Student extends Person{

boolean isMaster; studentID; // implicitely typed as int

}}

'''.compile [getCompiledClass("Person").assertNotNullgetCompiledClass("Student").assertNotNull

]}

}

both classes has been compiledsuccessfully

Page 27: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 27

A Simple Example: Beans-- Testing Code Generator using JUnit --

@Testdef void playWithGeneratedJavaCode() {

'''bean Person{string name;}bean Student extends Person{

boolean isMaster; studentID; // implicitely typed as int

}}

'''.compile [getCompiledClass("Student").newInstance => [

assertNull(it.invoke("getName"))val aName = "Johnson"it.invoke("setName", aName) // invoking inherit methodassertEquals(aName, it.invoke("getName"))val anInt = 1234it.invoke("setStudentID", anInt)

assertEquals(anInt, it.invoke("getStudentID"))]

]}

create instanceof Student and invoke setter/getterby reflection

Page 28: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 28

Summary

• Differences of domain-specific and general-purpose

languages

• Short overview on purpose and architecture of

Xtext

• Gone through small example (hopefully) showing the

efficiency gain

Page 29: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 29

Summary

• Differences of domain-specific and general-purpose

languages

• Short overview on purpose and architecture of

Xtext

• Gone through small example (hopefully) showing the

efficiency gain

Try it out by yourself! Xtext is very versatile and stable.

Page 30: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 30

Thank you!

Page 31: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 1

How to write a PhD thesis in Germany

Thomas [email protected] (temporary *)

NSU Tech Talk; Akademgorodok, 2015-11-24

Guest Lecturer at:

Home University:

* My stay at Novosibirsk State University is supported by DAAD (German Academic Exchange Service).

Page 32: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 2

What do you like Germany for?

Source of map: "Deutschland topo" by Botaurus-stellaris - Own work. Licensed under CC BY-SA 3.0 via Commons -

https://commons.wikimedia.org/wiki/File:Deutschland_topo.jpg#/media/File:Deutschland_topo.jpg

Page 33: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 3

What do you like Germany for?

Source of map: "Deutschland topo" by Botaurus-stellaris - Own work. Licensed under CC BY-SA 3.0 via Commons -

https://commons.wikimedia.org/wiki/File:Deutschland_topo.jpg#/media/File:Deutschland_topo.jpg

Cultural heritage(literature, music,

architecture)

Social welfare

Innovative companies

High-quality products(„Made in (West-)Germany“)

Efficiency

German beer :-)

Page 34: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 4

Up-/Downsides of Efficiency

Page 35: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 5

Up-/Downsides of Efficiency

Ups

- high wages

- cheap products/food

- as a country: strong

economic position

(much more export

than import)

Page 36: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 6

Up-/Downsides of Efficiency

Ups

- high wages

- cheap products/food

- as a country: strong

economic position

(much more export

than import)

Downs

- high unemployment

rate

- expensive workplaces

do not call a

craftsman ...

- high pressure on

employees

Diesel Gate at VW

Page 37: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 7

Efficiency also in Academia

• Comparing Student/Employee ratio of

- Hochschule für Technik und Wirtschaft (HTW) Berlin

University of Applied Sciences

- Humboldt-University (HU) Berlin

- Novosibirsk State University (NSU)

0

5000

10000

15000

20000

25000

30000

35000

HTW Berlin HU Berlin NSU

Size of Universities

Employees Students

Page 38: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 8

Efficiency also in Academia

• Comparing Student/Employee ratio of

- Hochschule für Technik und Wirtschaft (HTW) Berlin

University of Applied Sciences

- Humboldt-University (HU) Berlin

- Novosibirsk State University (NSU)

0

5

10

15

20

25

30

HTW Berlin HU Berlin NSU

Students per Employee

0

5000

10000

15000

20000

25000

30000

35000

HTW Berlin HU Berlin NSU

Size of Universities

Employees Students

Page 39: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 9

Efficiency also in Academia

• Comparing Student/Employee ratio of

- Hochschule für Technik und Wirtschaft (HTW) Berlin

University of Applied Sciences

- Humboldt-University (HU) Berlin

- Novosibirsk State University (NSU)

0

5

10

15

20

25

30

HTW Berlin HU Berlin NSU

Students per Employee

0

5000

10000

15000

20000

25000

30000

35000

HTW Berlin HU Berlin NSU

Size of Universities

Employees Students

This is the paradise !!!

Page 40: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 10

My Career

1990-97 Study of Computer Science at HU Berlin

1997-99 Research Assistent at HU Berlin

1999 How to continue? Hard decision!

1999-03 Doctoral Student at University of Karlsruhe

(today: KIT)

2003-07 Post-Doc, École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland

2007-11 Senior Engineer in small software company, Berlin

2011 -- Professor at HTW Berlin

Page 41: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 11

My Period of Writing PhD Thesis

• 2 years preliminary research work at HU Berlin

• my group in Karlsruhe

- 2 professors

- 2 post-docs

- 4 phd students

funding from DFG (Deutsche Forschungsgemeinschaft): salary,

equipement, travelling

basically no teaching obligations

- appr. 5-10 student assistents

Page 42: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 12

My Period of Writing PhD Thesis

• 2 years preliminary research work at HU Berlin

• my group in Karlsruhe

- 2 professors

- 2 post-docs

- 4 phd students

funding from DFG (Deutsche Forschungsgemeinschaft): salary,

equipement, travelling

basically no teaching obligations

- appr. 5-10 student assistents

We have the worst PhD supervisor ever, because he does not supervise us!

Page 43: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 13

My Period of Writing PhD Thesis

• 2 years preliminary research work at HU Berlin

• my group in Karlsruhe

- 2 professors

- 2 post-docs

- 4 phd students

funding from DFG (Deutsche Forschungsgemeinschaft): salary,

equipement, travelling

basically no teaching obligations

- appr. 5-10 student assistents

We have the worst PhD supervisor ever, because he does not supervise us!

We have the best PhD supervisor ever, because he does not supervise us!

Page 44: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 14

How to find open Research Position?

• Ask your professor/supervisor here in Nsk

- people meet at conferences/workshops and

disseminate open positions

• Go to www.academics.de

- offers alert service

- informative links

Page 45: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 15

Types of PhD Positions• assistent position at university (Landesstelle)

+ contract extension no problem

- sometimes time-consuming teaching obligations

• research position at university (e.g. DFG financed)

+ focus on research; no teaching

- sometimes hard to get project extension

• position at research institute (Fraunhofer, Leibniz)

+ working on industry problems

- overloaded with work to reach next milestone

• research position in industry (Daimler Benz, Siemens)

+ working on industry problems

- no strong supervision; danger to become 'ordinary' project member

Page 46: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 16

Initiative for Academic Excellence

• Initiated by chancellor Gerhard Schröder

Idea: Universities and clusters can apply for

special status "Place of Excellence"

- selected universities get huge research money from

Federal budget

- highly competitive (only 5-10 universities got status)

- only already renowned universities have chance to

become successful

Rational: Germany wants to "become better" in world-

wide rankings

Page 47: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 17

Consequences of Excellence Initiative

• currently a lot of money "in the system"

• many interesting projects

• a lot of open positions :-)

- also due to the current very good job market

many talented graduates go to industry

Page 48: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 18

Consequences of Excellence Initiative

• currently a lot of money "in the system"

• many interesting projects

• a lot of open positions :-)

- also due to the current very good job market

many talented graduates go to industry

!!! However !!!

- still only non-permanent positions

- becoming a professor after PhD project became

even more difficult (due to many qualified colleages

that completed PhD as well)

Page 49: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 19

Will I have enough money to survive?• as a PhD student: no fees to be paid

Page 50: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 20

Will I have enough money to survive?• as a PhD student: no fees to be paid

• Salary usually according to Tv-L 13: currently 3500 € per month

- from this appr. 50% reduction for taxes, health insurance,

pension plan

- !Attention! some research projects offer only 50% jobs

"officially" 50% workload, but for sure only 50% payment

Page 51: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 21

Will I have enough money to survive?• as a PhD student: no fees to be paid

• Salary usually according to Tv-L 13: currently 3500 € per month

- from this appr. 50% reduction for taxes, health insurance,

pension plan

- !Attention! some research projects offer only 50% jobs

"officially" 50% workload, but for sure only 50% payment

• Some prices:

- lunch in cafeteria: appr. 4 €

- food from supermarket: appr. 150 € per month

- 1-room flat in Berlin: from 400 € per month

Page 52: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 22

Final Recommendations• Do not worry about German language skills

- helpful in private life, but not mandatory at university

• my favourite position: research at university with professor

having 3-4 PhD students

• getting an 1-year-contract initially is rather normal

• publications

- do not wait too long with your first one

- write only if you found out something worth to be told

- also read books/articles on "How to write a good paper?/How to give a good talk?"

Page 53: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 23

Final Recommendations

Prof. Tom Henzinger: „Strive always to be as good as you can!“ (when writing applications,writing papers, giving talks)

Page 54: Xtext project and PhDs in Gemany

T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24 24

Thank you!