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

Here are two recommendations I'd like to give when designing a textual DSL:
- 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.
- Do not use noisy begin...end 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:

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


Good advice! I’ve just started a new DSL and decided to give xtext a try. It took me a little bit to feel comfortable, but now that I am, I’m very impressed! Keep up the good work.
Hi Peter,
thanks for the article … I guess it is a good idea to make this subject an topic to discuss! I am sure that there is a lot to learn in future if the DSL hype continuous to grow like these days.
I fully understand and agree with your recommendations … but what do you think about curly braces to “group” things and semicolons as EOL Terminals?
E.g.
element Foo {
child Bar "Bar";
child Boo;
}
element Apples {
child Seeds "1200";
}
Maybe it is because I have a development background but this would feel and look fine for me … wheras without at least curly braces I would have the feeling that the structure is not obvious enough – any other thoughts?
@Scott: thanks for the encouraging feedback!
@Wolfgang: I agree, “curlies” are nice to group things and I regularly use them in my DSLs. I just wanted to show the two extremes. With respect to semicolons: I have become used to NOT using them in DSLs, as I feel the really add a lot of noise. Usually, you do not need them. It’s probaby a matter of taste