Jim Driscoll's Blog

Notes on Technology and the Web

What is a DSL, anyway? Why should you care?

leave a comment »

As part of my job at Oracle, working on the ADFm portion of ADF,  I work on DSL features in Groovy.  (ADFm uses Groovy as its extensibility layer, in much the way that HTML pages use JavaScript.)  I’m interested in blogging about the (fairly neat) stuff I’ve learned, but now that I think of it, it’s quite possible that many people reading this won’t really know what a DSL is…  So let’s talk about that for  a minute.

DSL stands for Domain Specific Language, and it essentially means a purpose built language designed for a specific task:  HTML, Unix scripting, and SQL are three you’re almost certainly familiar with.  Contrast this with a a general purpose language, like Java, or for that matter, Groovy, where the language is open ended, and intended to deal with almost any task.  So far, simple enough, and this is all dealt with very adequately in the Wikipedia article on the topic.

But here’s the thing:  When you’re creating a DSL with Groovy (or, for that matter, with many metaprogramming languages), you’re not generally creating a limited language – you’re creating a domain aware extension to the existing general purpose language you’re using as a base – unless, of course, you do a great deal of additional work to disable the existing language features.

So, what to call such a beast?  What to call a domain aware general purpose language?  I’ve noticed that most people just call it a DSL, so that’s the convention I’ll follow in the following posts.  Computer science purists, please forgive me.

Why should you care about DSLs?  Why learn how to create one?  Well, I can only answer for me, but I can tell you that when I was a still a wee little programmer, the people who created the languages I used were people I really looked up to, and the idea of creating one of my own, or even just knowing how, is something that’s really exciting to me.  On a more practical side, if you have this in your toolbox, ways to use it present themselves all the time.  Want to create a really usable, readable testing framework around your Selenium tests?  A DSL may fit the bill.  Need to present a text heavy interface to your users for open-ended data entry?  A simple object definition language DSL seems appropriate.  And so on.  Like all techniques, it can be overused (factories, anyone?), but DSLs have their place.   Plus, it’s just so darn cool.

In the following series of posts, I’ll go over the basics of creating a DSL.  No Groovy knowledge will be required or assumed – just Java.  Follow along – I think you’ll like it.


Written by jamesgdriscoll

March 12, 2012 at 7:22 PM

Posted in DSL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: