Peter Friese

Developer Advocate / Mobile Developer / Public Speaker

Noisy DSLs

| Comments

I recently came across some DSLs which had some defects. Let’s look at a sample I quickly hacked together with Xtext:[

Resource - Demo/demo.mydsl - Eclipse SDK


Here are two recommendations I’d like to give when designing a textual DSL:

  1. Don’t use uppercase letters in the keywords of your DSL, unless you either really like them. In the sample DSL, the keywords (Element, EndElement, Child, Endchild all start with an uppercase letter, which makes it cumbersome to edit the DSL script (you need to press the shift key a lot). Back in the days when we didn’t have syntax highlighting, UPPERCASE keywords made a lot of sense as they helped to draw a better distinction between the keywords, the variables and the constants (strings and numbers) of a program. Nowadays, it is hard to find an IDE which does not offer syntax highlighting, so this argument does not hold any more.

  2. Do not use noisy beginend syntax constructions. They do not increase readability of your DSL script and they add to the amount of code to be typed.

Here is an improved version of the DSL script: [

Resource - Demo/demo.mydsl1 - Eclipse SDK


By removing the Endelement and Endchild keywords, we have improved readability a lot. Using lowercase keywords has lowered the effort you need to invest to key in the DSL script. And – honestly – don’t we all like to be lazy at times? After all, one of the goals of DSLs is to make your work easier and more efficient.

That being said, have a great weekend!

By the way, if you need help designing a DSL with Xtext – I and the entire Xtext team are happy to assist you. Just drop me a line (peter at itemis dot com) or hop on to our professional support site