The Artima Developer Community
Sponsored Link

Artima Developer Spotlight Forum
How and When to Develop Domain-Specific Languages?

10 replies on 1 page. Most recent reply: May 5, 2006 11:24 AM by Pier Johnson

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 10 replies on 1 page
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

How and When to Develop Domain-Specific Languages? Posted: Mar 9, 2006 9:56 AM
Reply to this message Reply
Advertisement
A recent ACM Computing Survey article by Marjan Mernik, Jan Heering, and Anthony M. Sloane looks at domain-specific languages both from the user's and from the designer's point of view. They categorize such languages, rate various types of DSLs according to the productivity boost they offer, and provide design guidelines to help create effective DSLs.

Domain-specific languages [...] are languages tailored to a specific application domain. They offer substantial gains in expressiveness and ease of use compared with general-purpose programming languages in their domain of application.

DSL development is hard, requiring both domain knowledge and language development expertise. Few people have both. Not surprisingly, the decision to develop a DSL is often postponed indefinitely, if considered at all, and most DSLs never get beyond the application library stage.

Although many articles have been written on the development of particular DSLs, there is very limited literature on DSL development methodologies and many questions remain regarding when and how to develop a DSL.

To aid the DSL developer, we identify patterns in the decision, analysis, design, and implementation phases of DSL development. Our patterns improve and extend earlier work on DSL design patterns. We also discuss domain analysis tools and language development systems that may help to speed up DSL development. Finally, we present a number of open problems.

What do you think of the role of DSLs in enterprise application development? If you have tried Rails, has it influenced your approach to using, or not using, DSLs?


Merriodoc Brandybuck

Posts: 225
Nickname: brandybuck
Registered: Mar, 2003

Re: How and When to Develop Domain-Specific Languages? Posted: Mar 9, 2006 11:12 AM
Reply to this message Reply
I've not tried Rails. The company I work for has many products that have API's that users can use. We've never gone so far as to do a full Domain Specific Language. We've talked about it from time to time, but when it comes down to it, in most cases, I think libararies are better. The people that use our products and program to our API's have a very wide range of knowledge from people that should never be allowed near a keyboard to people that probably play around with lisp in their spare time.

Given this user base I think with an application library you remove a substantial part of the learning curve and make more users feel more comfortable faster with writing their own applications using your proprietary language or language extension. They may have to learn a few new function names and pick up a couple of new data structures but this is less intimidating than picking up a whole new language, even if that languages is a subset of or looks similar to something you already know. VB6/VB.NET/VBA/VBScript are all similar enough where you can in a lot of cases jump from one to the other without too much effort yet different enough that going from one to the other can really be a pain in the neck.

For the amount of time it takes to design a good DSL I don't think you get much bang for your buck in most cases. I think a great deal of this decision depends on your targeted user base. If you are tageting a narrow group that has either programming expertise or domain expertise and they are going to use the language a lot then I think it pays off. If you are targeting people that are not expert and they are going to be writing code rarely then I think you are much better off with a simple API or library to be used from a language the target audience is familiar with.

Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: How and When to Develop Domain-Specific Languages? Posted: Mar 10, 2006 12:25 AM
Reply to this message Reply
Just a small note here: any API is a DSL...

V.H.Indukumar

Posts: 28
Nickname: vhi
Registered: Apr, 2005

Re: How and When to Develop Domain-Specific Languages? Posted: Mar 10, 2006 2:01 AM
Reply to this message Reply
It seems to me that almost all major applications have the so called 'configuration files' written in XML or some other format. Most of them are complicated enough to be considered a DSL. What they do not do is to go ahead and provide their own DSL. I think an easier approach would be to provide APIs and provide bindings with a well known scripting language such as Ruby. An example I would like to take is those products that have APIs written in Java and over BSF provide bindings to Jython/JRuby.

Anomander Rake

Posts: 1
Nickname: anomander
Registered: Mar, 2006

Re: How and When to Develop Domain-Specific Languages? Posted: Mar 10, 2006 8:35 AM
Reply to this message Reply
I find DSL's intriguing. However, there are some problems with them that I cannot resolve in my own mind.

The degree of difficulty in finding people to develop in the chosen language. As the software development profession exists currently, developers find it more practical - in seeking work - to learn a general language that can be applied across a broad number of domains. In a DSL world, will a developer who has been working 10 years with a medical DSL be able to find work in a finance business?

Businesses are not necessarily single-domain specific. For example, my former employer had both manufacturing and finance business units. Do you use separate languages for each business unit? How do you resolve the differences when cross-unit projects are undertaken?

Within a single-domain business, many sub-domains exist. For example, a hospital has both a medical and finance software needs. Does an IT staff use a medical DSL or a finance DSL? Or, is finance included in the medical DSL?

If a subset of the questions I've posed have been answered already, I'd appreciate reading any material you can point me to; DSL's are intriguing and may lead to development efficiencies. I'm just not certain whether or not they will lead to the language equivalent of "stove-pipe" applications.

Merriodoc Brandybuck

Posts: 225
Nickname: brandybuck
Registered: Mar, 2003

Re: How and When to Develop Domain-Specific Languages? Posted: Mar 10, 2006 8:45 AM
Reply to this message Reply
> Just a small note here: any API is a DSL...


I think there is some grey area where the two overlap but I tend to think of them as different enough in degree that I think of them separately. Maybe that's flawed thinking.

Jules Jacobs

Posts: 119
Nickname: jules2
Registered: Mar, 2006

Re: How and When to Develop Domain-Specific Languages? Posted: Mar 10, 2006 9:02 AM
Reply to this message Reply
I have tried Rails, and I don't know if it is a DSL. DSL means domain-specific-language. So that's a language. If you're used to Java, C#, or another static language it probably looks like a DSL. If you're used to python, it will look more like a group of classes and functions, with some other weird things. If you're used to Ruby, you'll know that this is not a DSL, but just a library like any other. In TCL, Lisp, and many other languages you can create APIs that look even more like a separate language.

For example, the Ruby-Make "DSL" in a C#/Java Like language:


using task;

public class ATask : Task
{
public void execute()
{
doStuff();
}
}

----------

using task;

class TaskApplication
{
public static void Main()
{
Task.addtask(new ATask());
Task.runAll();
}
}


In Ruby:


task :a_task do
do_stuff()
end


In Lisp:


(task a-task
(do-stuff))


The first example doesn't look like a DSL because you can clearly see this is not a new language. There are too many aspects (such as a class, a main function, etc) that are not domain specific. The most common way to handle this is to create an xml "dsl", or configuration. A static language tries to be a dynamic one ;-).
The ruby version looks more like a domain specific language, but there are some things a Ruby programmer would recognize: the "do" and "end" keywords, and the syntax to create a symbol: ":a_task".
In the Lisp code, there are no keywords. The domain specific language is truly domain specific. The only weird things are the (()). But unfortunately, the parens make it possible to create a DSL.


class Posts < ApplicationController
def show
code()
end

def new
code()
end
end


vs:


(controller posts
(action show
(code))
(action new
(code)))


This is more domain specific, because it contains no language keywords (def, class, end).

Or maybe a model from django:


class Post(meta.Model):
author = meta.ForeignKey(Author)
title = meta.CharField()
content = meta.TextField()


or:


(model post
(belongs-to author)
(attributes
title string
content text))


So what makes an api a DSL? This is not entirely clear, because most DSLs will have some non DS aspects, and you can't say: "if an api contains less than n non DS aspects, it is a DSL".
I think most people will agree that my first Java/C# like examle is not a DSL. But is the Django model a DSL?

DSLs are about abstractions. You can create better DSLs in languages with better ways to abstract. Many languages support procedural abstrations (FORTRAN, Python, Ruby, Lisp). A lot support object oriented abstractions (Python, Ruby, Lisp). A few support functional abstractions (Ruby, Lisp). Even less languages support syntactical abstrations (Lisp).

(note that because these languages are turing equivalent, you could write a lisp interpreter in FORTRAN, and have all these abstractions).

So "How and When to Develop Domain-Specific Languages?"?

How:

By choosing a language that supports powerful abstractions.

When:

Just create an appropriate abstraction for difficult things.

If you notice that you want to generate a form, and you're doing it this way:

(write-html "<form>
<input type="text" name="title" />
<textarea name="content"></textarea>
<input type="submit" value="save" />
</form>")

Create an abstraction:

(form
(text-field :title)
(text-area :content)
(submit-button "save"))

Or:

form {
text_field :title
text_area :content
submit_button "save"
}

Or (in Java/C#):

// form.xml
<?xml version="1.0" ?>
<form>
<text-field name="title" />
<text-area name="content" />
<submit-button caption="save" />
</form>

and in your code:

parseFormFromXMLAndPrintResult('form.xml');

Or, offcourse:

// form.lisp
(form
(text-field :title)
(text-area :content)
(submit-button "save"))

and in your code:

parseFormFromLispAndPrintResult('form.lisp');

To make it easier next time.

Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: How and When to Develop Domain-Specific Languages? Posted: Mar 13, 2006 6:49 AM
Reply to this message Reply
> > Just a small note here: any API is a DSL...
>
>
> I think there is some grey area where the two overlap but
> I tend to think of them as different enough in degree that
> I think of them separately. Maybe that's flawed thinking.

Technically speaking, a DSL is a kind of 'sub-language' in a programming language geared towards solving a specific set of problems.

But that description is also suitable for an API. Take a GUI library, for example: does not it offer specific semantics to the domain of UIs? it does. It does not matter if an API has the same syntax as the language it is hosted on; conceptually, an API offers a new "language" for solving a problem.

melc helion

Posts: 1
Nickname: doctors
Registered: Mar, 2006

Re: How and When to Develop Domain-Specific Languages? Posted: Mar 14, 2006 12:14 AM
Reply to this message Reply
i really like this topic , ive learned a lot. .

Gregg Irwin

Posts: 16
Nickname: greggirwin
Registered: Jan, 2004

Re: How and When to Develop Domain-Specific Languages? Posted: Mar 26, 2006 12:52 PM
Reply to this message Reply
> The degree of difficulty in finding people to develop in
> the chosen language. As the software development
> profession exists currently, developers find it more
> practical - in seeking work - to learn a general language
> that can be applied across a broad number of domains. In a
> DSL world, will a developer who has been working 10 years
> with a medical DSL be able to find work in a finance
> business?

The problem here is that we tend to focus on our own domain (programming), rather than the problem domain. If your experience lies in the medical field, why would I assume that because you know Java, that you would be able to do finance work? Most of the problems in programming come from understanding the domain. If you know about finance, you can much more easily learn a new programming syntax than if you know the programming language we use but don't know anything about the domain.

> Businesses are not necessarily single-domain specific. For
> example, my former employer had both manufacturing and
> finance business units. Do you use separate languages for
> each business unit? How do you resolve the differences
> when cross-unit projects are undertaken?

Yes, you should use the right language for the job. You have to talk about things in terms of the domain anyway, right? How do you resolve the differences when not using DSLs? You have different data structures, properties, and behaviors you need to express, don't you? Is a "time period" the same, semantically, in terms of manufacturing and finance?

> Within a single-domain business, many sub-domains exist.
> For example, a hospital has both a medical and finance
> software needs. Does an IT staff use a medical DSL or a
> finance DSL? Or, is finance included in the medical DSL?

You use both; if you're lucky, you have a "master" language that makes it easy to create and embed these DSLs, so you have the best of all worlds.

> If a subset of the questions I've posed have been answered
> already, I'd appreciate reading any material you can point
> me to; DSL's are intriguing and may lead to development
> efficiencies. I'm just not certain whether or not they
> will lead to the language equivalent of "stove-pipe"
> applications.

The biggest problem I see is that people think of DSLs as being more broad than they really tend to be, or confusing because "I'll have all these little languages, rather than just one". e.g. printf uses a DSL for its format specs, SQL is a DSL, etc. Both have cover a specific domain. One is much bigger than the other, but they are both used alongside other languages successfully; and SQL is also used standalone.

Pier Johnson

Posts: 2
Nickname: pier
Registered: May, 2006

Re: How and When to Develop Domain-Specific Languages? Posted: May 5, 2006 11:24 AM
Reply to this message Reply
Most High Priests of Academia with their false claims of scientia continue to preach foolishness. WITHOUT reading the article, I can unequivocally state that these persons (Marjan Mernik, Jan Heering, and Anthony M. Sloane) don't know about which they write.

In the "real world", a Domain-specific Language (DL) is any mutually agreed upon means of expression to convey meaning. For example, "commodity" traders flashing hand signals for buy and sell orders convey meaning to each other using their Domain-specific Language.

Within the realm of computing, the true concept of a Domain-specific language (DL) requires:

1) rules that specify the making of arbitary strings of data, which

1.1) convey meaning
1.2) represent an action-specific thread of executable routines

2) an engineered machine (pattern machine) that

2.1) accepts variable length strings that are unpredictable within their nature

2.2) causes the execution mechanism of the CPU to traverse the pattern of the action-specific thread, implement the pattern control logic expressed by such a thread and change the state of the ENTIRE computer

So what fits this truth?

1) A PC is an engineered machine that accepts the DL C-language. One writes using the rules of C-language to manipulate hardware.

2) REBOL is an engineered machine that "interprets talk" on behalf of a PC. REBOL accepts high-level rules that express real world concepts (a dialect), traverses any arbitrary action-specific thread that completes one expression of this dialect and translates this expression into instruction on behalf of the PC

3) Like REBOL, Forth is an engineered machine that accepts sheets of words expressed into a DL. A sheet of Forth DL allows a person to write high-level expression that represents real world DL into a "thread" of executable routines represented by their addresses and executable by the Forth "address interpreter". Forth translates on behalf of the substrate PC.


What imposters do not fit this truth?

The following class-based, Aristotelian (Socialist-thinking indoctrination) junk:

C++; Java, C#, Python, Ruby, et. al

None of the aforementioned can ever express a DL and interpret a DL since none are engineered machines (virtual computers). At best, most of these are token interpreters.


NOTICE: It's wrong, always and everywhere to refer to a DL as a DSL. Within PROPER English, Domain-specific acts as a SINGLE word, not two words. Hence it's DL, not DSL (incorrectly, domain specific language). As usual, High Priests of Academia cannot speak English properly and hence can never express truth about any concept.

Flat View: This topic has 10 replies on 1 page
Topic: Lance Andersen on the JDBC 4.0 SQLXML Interface Previous Topic   Next Topic Topic: LDAP or a Database? Where to Store User Data

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use