Key Takeaways Chapter 1 of Implementing Domain-Specific Languages with Xtext and Xtend – Second Edition

Here’s some personal notes and key takeaways from Chapter 1 of Implementing Domain-Specific Languages with Xtext and Xtend – Second Edition. First part is an introduction to DSL, why it’s here and why it matters. Typically a DSL is here to solve a very specific problem faster and easier instead of using a GPL.

  • General Purpose Languages (GPL) like Java and C#
  • Domain Specific Languages (DSL) like SQL and HTML

Programmers can’t be expected to produce bug-free code

  • Software is an incredibly complex artifact
  • Real world vs code represent a gap

Because many systems has safety-critical

  • Humans might be harmed
  • Privacy violations which breaks critical infrastructure
  • Critical loss of money
  • Physical damage to system due to bugs

It arguments that XML, though it could be used, is very clumsy and machine readable but not very human-readable. Furthermore if you end up writing XML it can be very tedious with a lot of boilerplate code which is removed for a DSL. The same goes for JSON, though it is a bit better but still it’s not clean enough.

person {

JSON vs a DSL example

John Do (30)

Implementation of a DSL

First of all the DSL needs to know how to read the program so the program needs to respect the syntax for the parser to be able to read it in the first place. There’s a structure it needs to follow.

  • ‘John Do’ is two identifiers
  • Start brackets a seperator
  • 30 is a number
  • End bracket is also a seperator

It tells that the parser relies on lexical analysis. After the parsing phase the abstract syntax tree (AST) begins which includes type checking called semantic analysis.

The book will cover Eclipse IDE using the plugin Xtext

The examples a public available at github: