Xtext project and PhDs in Gemany

Xtext project and PhDs in Gemany

Xtext: Eclipse-based framework for defining Domain-Specific Languages (DSLs) and a couple of words about scientific career in Germany

Thomas Baar, Hochschule für Technik und Wirtschaft Berlin

«Предметно-специфичные языки (Domain-specific languages, DSLs) привлекают к себе всё больше интереса как в академических кругах, так и в индустрии. Xtext — это фреймворк на базе платформы Eclipse, позволяющий определять текстовые DSL для самых разнообразных нужд и реализовывать их на базе JVM. Среди прочего, Xtext предоставляет интуитивно понятный формализм на основе EBNF, позволяющий определить грамматику вашего DSL, а также множество инструментов для задания правил валидации синтаксических деревьев, выполнения рутинных задач типа отслеживания пространств имен или форматирования кода, а также для собственно кодогенерации.

Помимо рассказа о проекте Xtext мы поговорим о плюсах, минусах и подводных камнях написания PhD в Германии»

E51d363aa46f4d059d54a15e0bcd8e6f?s=128

Tech Talks @NSU

November 24, 2015
Tweet

Transcript

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

    framework for defining Domain-Specific Languages (DSLs) Thomas Baar thomas.baar@ccfit.nsu.ru (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).
  2. 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.
  3. 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!
  4. 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.
  5. T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 5 DSL Examples

    Domain Typesetting Language Latex Source: Britannica kids. kid.eb.com
  6. T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 6 DSL Examples

    Domain Automatic Software Build Language make
  7. T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 7 DSL Examples

    Domain Chemistry Language Mendeleev's periodic system of chemical elements
  8. T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 8 DSL Examples

    Domain Process Description Language Harel's statecharts
  9. 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"
  10. 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
  11. 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
  12. 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.
  13. T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 13 Overview on

    DSL Definition DSL-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.
  14. T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 14 More detailed

    DSL-Definition Workflow
  15. T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 15 Example Project

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

    Example: Beans -- Create an Xtext Project --
  17. T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 17 A Simple

    Example: Beans -- Define the Grammar --
  18. T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 18 A Simple

    Example: Beans -- Define the Grammar -- Header Start Rule Feature in generated EMF class Cross-reference Keyword Optional Occurence
  19. 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 generated EMF class Cross-reference Keyword Optional Occurence The formalism for defining a grammar is a DSL! This DSL has been implemented by Xtext itself ;-)
  20. T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 20 A Simple

    Example: Beans -- Testing the Parser using JUnit -- Pre-defined helper classes String templates (enclosed by ''' ) Extension method (actually defined in ParserHelper and not in String)
  21. 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' @Check def 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 erroneous under certain circumstances
  22. T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 22 A Simple

    Example: Beans -- Testing the Validator using JUnit --
  23. 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)
  24. 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» «EN «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
  25. T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 25 A Simple

    Example: Beans -- Enjoy the Code Generator :-) -- One input file (written in our DSL) Location of generated artifacts Three output files (written in target language)
  26. 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 @Test def void testTwoCompiledClasses() { ''' bean Person{string name;} bean Student extends Person{ boolean isMaster; studentID; // implicitely typed as int } } '''.compile [ getCompiledClass("Person").assertNotNull getCompiledClass("Student").assertNotNull ] } } both classes has been compiled successfully
  27. T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 27 A Simple

    Example: Beans -- Testing Code Generator using JUnit -- @Test def 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 method assertEquals(aName, it.invoke("getName")) val anInt = 1234 it.invoke("setStudentID", anInt) assertEquals(anInt, it.invoke("getStudentID")) ] ] } create instance of Student and invoke setter/getter by reflection
  28. 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
  29. 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.
  30. T.Baar: NSU TechTalk, The framework Xtext. 2015-11-24 30 Thank you!

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

    1 How to write a PhD thesis in Germany Thomas Baar thomas.baar@ccfit.nsu.ru (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).
  32. 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
  33. 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 :-)
  34. T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24

    4 Up-/Downsides of Efficiency
  35. 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)
  36. 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
  37. 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
  38. 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
  39. 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 !!!
  40. 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
  41. 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
  42. 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!
  43. 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!
  44. 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
  45. 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
  46. 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
  47. 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
  48. 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)
  49. 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
  50. 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
  51. 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
  52. 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?"
  53. 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)
  54. T.Baar: NSU TechTalk, Writing a PhD Thesis in Germany. 2015-11-24

    24 Thank you!