I an well versed with Java. I have few usecases that benefit from a DSL. Before I start on building them, I would like to take input from people who already built them. Can someone help me understand what are pros and cons of writing DSL's in Groovy and xtext.
Asked
Active
Viewed 961 times
5
-
You need to be very clear what you mean by "DSL". Have you seen the famous 10-question checklist at http://www.oreillynet.com/onlamp/blog/2007/05/the_is_it_a_dsl_or_an_api_ten.html ? Many languages "enable DSL's" by enabling minimally working examples. Groovy at Codehaus, for example, doesn't allow their command expressions inside function calls, making it virtually useless. – Vorg van Geir Nov 18 '11 at 09:05
-
1@VorgvanGeir Can you explain _"...doesn't allow their command expressions inside function calls..."_? – tim_yates Nov 18 '11 at 10:16
-
@tim_yates println(println "a") doesn't parse – Vorg van Geir Nov 18 '11 at 11:17
-
@VorgvanGeir Ahh, I see, you mean omiting the braces on the internal call... (as `println( println( 'a' ) )` parses ok) – tim_yates Nov 18 '11 at 11:25
-
@tim_yates println(println('a')) parses ok but it's no longer a command expression. Command expressions don't work inside parens or brackets. Virtually every Groovy demo pitching it as a DSL uses an example of a paren-free function call at the top level only. The marketing for Groovy 1.8 made a big fuss about enabling them after the = sign also, but they don't work when nested anywhere. – Vorg van Geir Nov 18 '11 at 22:33
-
You should list your use cases, since it really depends on them whether a DSL pays of or well designed API is sufficient. – Sven Efftinge Nov 18 '11 at 10:47