Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

For what kind of problems do you write a DSL?

I'm just curious about Domain-Specific Languages. I have seen them several times in articles, and it seems that they can be used outside assurance or bank data definition problems.

So I come to SO to have some concrete input.

Did you ever use a DSL? Write one. If yes, what's it feel like?

Do you think one of your projects could be better (more productive, more maintainable, ...) with a DSL?

Edit : I'm sorry to put this after, but i was meanning a specific DSL that you wrote yourself. It's exclude Tex, HTML, Make , SQL. I fact, the question was more : "writing a DSL"

like image 805
Antoine Claval Avatar asked Jul 10 '09 12:07

Antoine Claval


People also ask

What is the purpose of domain-specific language?

Overview. A domain-specific language is created specifically to solve problems in a particular domain and is not intended to be able to solve problems outside of it (although that may be technically possible). In contrast, general-purpose languages are created to solve problems in many domains.

What is the example of DSL?

A good example of a DSL is HTML. It is a language for the web application domain. It can't be used for, say, number crunching, but it is clear how widely used HTML is on the web. A GPL creator does not know where the language might be used or the problems the user intends to solve with it.

What is DSL code?

A Domain Specific Language is a programming language with a higher level of abstraction optimized for a specific class of problems. A DSL uses the concepts and rules from the field or domain.


1 Answers

I'd say there is quite a continuum between very readable API as a weak form of DSL (what some call a fluent interface), an internal DSL as something in between and a full grammar-defined external DSL on the other end.

The weakest form is something that I kind of always try to achieve (i.e. make the API as closest to the problem domain as possible). A DSL on the other end of the continuum makes a lot of sense if non-programmers will be using the software, e.g. to enter data.

And with a framework like Xtext even a full external DSL, including an editor supporting syntax coloring and error checking is much easier to implement than it might initially seem.

like image 100
Fabian Steeg Avatar answered Sep 24 '22 17:09

Fabian Steeg