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 ).
2024 questions
181
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,195
  • 4
  • 26
  • 21
116
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
  • 60,096
  • 9
  • 116
  • 138
115
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,091
  • 15
  • 60
  • 106
88
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,249
  • 2
  • 21
  • 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
  • 5,537
  • 13
  • 59
  • 106
54
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,041
  • 1
  • 9
  • 16
48
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
  • 573
  • 1
  • 7
  • 8
39
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,209
  • 14
  • 25
38
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
  • 4,781
  • 1
  • 22
  • 36
34
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,525
  • 18
  • 19
31
votes
3 answers

Are there any Clojure DSLs?

Is there any DSL (Domain Specific Language) implemented in Clojure ?
Belun
  • 3,931
  • 6
  • 31
  • 48
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
  • 26,038
  • 13
  • 69
  • 90
29
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,021
  • 2
  • 31
  • 44
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
  • 90,223
  • 44
  • 210
  • 255
27
votes
7 answers

Can I define custom operator overloads in Javascript?

Is it possible to define custom operators between instances of a type in JavaScript? For example, given that I have a custom vector class, is it possible to use vect1 == vect2 to check for equality, whilst the underlying code would be something…
pimvdb
  • 141,012
  • 68
  • 291
  • 345
1
2 3
99 100