Designing Internal DSLs

Dynamic languages are well suited to designing and implementing internal DSLs. They have good metaprogramming capabilities and flexible syntax, and we can easily load and execute code fragments.

Not all dynamic languages are created equal, however.

I find it very easy to create DSLs in Ruby, for example. It is dynamically typed, parentheses are optional, the colon symbol (:) can be used instead of double quoting strings, and so on. Ruby’s elegance heavily favors creating internal DSLs.

Creating internal DSLs in Python can be a bit of a challenge. The significant whitespace can be a hindrance.

Groovy’s dynamic typing and metaprogramming capabilities help a great deal in creating internal DSLs. However, it’s picky ...

Get Programming Groovy 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.