Questions tagged [dsl]

Domain-Specific Language is a programming language intended for a particular application domain

A domain-specific language (DSL) is a programming language intended for a particular application domain.

Well-known examples that can be considered DSLs include for markup, for statistics.

There are three key points in above mentioned definition.

  1. Programming Language: DSL is a programming language, which is used by humans to instruct a computer to do something.
  2. Limited Expressiveness: DSL is not a general purpose language like C, Java, etc. It supports minimum features needed to support its domain. Programmer cannot build entire software system using DSL.
  3. Domain focus: DSL focuses on a small domain. The limited focus makes it easy to understand and easy to use.

Martin Fowler divides DSL mainly into two categories :

  1. A External DSL : it is a standalone language with its own custom syntax, but adopting other language such as XML syntax is common. Example of external DSLs are for database queries, languages.
  2. An Internal DSL : They are intrinsically embedded inside a general-purpose language, such as Lava (hardware description language on top of ), (build system on top of ), or (structured markup language on top of ).
2200 questions
198
votes
7 answers

How to convert a String to its equivalent LINQ Expression Tree?

This is a simplified version of the original problem. I have a class called Person: public class Person { public string Name { get; set; } public int Age { get; set; } public int Weight { get; set; } public DateTime FavouriteDay { get; set;…
Codebrain
  • 5,565
  • 4
  • 28
  • 21
136
votes
14 answers

What is a domain specific language? Anybody using it? And in what way?

I guess I am looking for some kind of intro and see if anybody have used it. Are there any particular advantages of using it? Wikipedia: domain-specific language (DSL) is a programming language or specification language dedicated to a particular…
Srikar Doddi
  • 15,499
  • 15
  • 65
  • 106
124
votes
1 answer

How Pony (ORM) does its tricks?

Pony ORM does the nice trick of converting a generator expression into SQL. Example: >>> select(p for p in Person if p.name.startswith('Paul')) .order_by(Person.name)[:2] SELECT "p"."id", "p"."name", "p"."age" FROM "Person" "p" WHERE…
Paulo Scardine
  • 73,447
  • 11
  • 124
  • 153
93
votes
6 answers

How to assert number of elements using Capybara with proper error message?

I know that in Capybara, you can do something like this: page.should have_css("ol li", :count => 2) However, assuming that page has for instance only one matching element, the error is not very descriptive: 1) initial page load shows greetings …
merryprankster
  • 3,369
  • 2
  • 24
  • 26
82
votes
13 answers

Android Studio Gradle DSL method not found: 'android()' -- Error(17,0)

I am attempting to run my project in Android Studio but the error appears below: I have followed many sources just to get this to run and have wound up here, but do not know what else to do. How can I configure this project to run? build.gradle: …
Sauron
  • 6,399
  • 14
  • 71
  • 136
55
votes
3 answers

What are the main differences between Jetbrains' MPS and Eclipse Xtext?

I have used Eclipse Xtext in several projects. I loved the ease of defining a grammar over an Ecore (meta)model and letting everything generated for you including awesome Eclipse plugin editor, but I was quite uncomfortable with the underlying EMF…
Karel Smutný
  • 1,100
  • 1
  • 9
  • 17
51
votes
6 answers

Mini-languages in Python

I'm after creating a simple mini-language parser in Python, programming close to the problem domain and all that. Anyway, I was wondering how the people on here would go around doing that - what are the preferred ways of doing this kind of thing in…
Reality
  • 613
  • 1
  • 8
  • 8
38
votes
1 answer

When would I want to use a Free Monad + Interpreter pattern?

I'm working on a project that, amongst other things, involves a database access layer. Pretty normal, really. In a previous project, a collaborator encouraged me to use the Free Monads concept for a database layer and so I did. Now I'm trying to…
Savanni D'Gerinel
  • 2,379
  • 17
  • 27
37
votes
5 answers

Is there any chance to write "C major" instead of "major C"?

I encountered a small aesthetic issue in my music project and it has been bugging me for some time. I have a type data Key = C | D | ... and I can construct a Scale from a Key and a Mode. The Mode distinguishes between e.g. a major and a minor…
Martin Drautzburg
  • 5,143
  • 1
  • 27
  • 39
35
votes
3 answers

How to parse text for a DSL at compile time?

Yes. That's right. I want to be able to paste an expression like: "a && b || c" directly into source code as a string: const std::string expression_text("a && b || c"); Create a lazily evaluated structure with it: Expr…
Benedict
  • 2,771
  • 20
  • 21
31
votes
3 answers

Are there any Clojure DSLs?

Is there any DSL (Domain Specific Language) implemented in Clojure ?
Belun
  • 4,151
  • 7
  • 34
  • 51
30
votes
3 answers

Dynamically define named classes in Ruby

I am writing an internal DSL in Ruby. For this, I need to programmatically create named classes and nested classes. What is the best way to do so? I recon that there are two ways to do so: Use Class.new to create an anonymous class, then use…
Little Bobby Tables
  • 5,261
  • 2
  • 39
  • 49
30
votes
3 answers

What does "DSL" mean in gradle?

While reading the Android NDK documentation, I came across the term "DSL". I don't know what it means exactly. Would you please tell me the full name of "DSL"? Documentation…
최완규
  • 333
  • 1
  • 3
  • 4
30
votes
6 answers

When should I use a Domain Specific Language?

I would like some practical guidance on when I should use a Domain Specific Language. I have found resources about advantages and disadvantages, but what kind of project would warrant its use? It seems like there is a big investment in time to…
Kekoa
  • 27,892
  • 14
  • 72
  • 91
27
votes
7 answers

What's the point of DSLs / fluent interfaces

I was recently watching a webcast about how to create a fluent DSL and I have to admit, I don't understand the reasons why one would use such an approach (at least for the given example). The webcast presented an image resizing class, that allows…
M4N
  • 94,805
  • 45
  • 217
  • 260
1
2 3
99 100