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
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
  • 151,816
  • 78
  • 307
  • 352
25
votes
7 answers

What is a DSL and where should I use it?

I'm hearing more and more about domain specific languages being thrown about and how they change the way you treat business logic, and I've seen Ayende's blog posts and things, but I've never really gotten exactly why I would take my business logic…
crucible
  • 3,109
  • 2
  • 28
  • 35
25
votes
3 answers

Is something in Swift like LINQ in C#

I know that Swift is relatively new yet, but I would like to know if Swift have anything like LINQ in C#? With LINQ I mean all the excellent tools like Standard Query Operators, Anonymous types, Object Initializer, etc.
Victor Sigler
  • 23,243
  • 14
  • 88
  • 105
25
votes
3 answers

Best design for generating code from an AST?

I'm working on a pretty complex DSL that I want to compile down into a few high level languages. The whole process has been a learning experience. The compiler is written in java. I was wondering if anyone knew a best practice for the design of…
Sam Washburn
  • 1,817
  • 3
  • 25
  • 43
24
votes
1 answer

What does :except => {:no_release => true} mean in Capistrano DSL

For example in: task :restart, :roles => :app, :except => { :no_release => true } do end
denysonique
  • 16,235
  • 6
  • 37
  • 40
24
votes
4 answers

How to construct QueryBuilder from JSON DSL when using Java API in ElasticSearch?

I'm using ElasticSearch as a search service in Spring Web project which using Transport Client to communicate with ES. I'm wondering if there exists a method which can construct a QueryBuilder from a JSON DSL. for example, convert this bool query…
Armstrongya
  • 795
  • 1
  • 6
  • 9
24
votes
2 answers

Extended computation expressions without for..in..do

What I mean by extended computation expressions is computation expressions with custom keywords defined via CustomOperation attribute. When reading about extended computation expressions, I come across very cool IL DSL by @kvb: let il =…
pad
  • 41,040
  • 7
  • 92
  • 166
23
votes
2 answers

In Kotlin, how do I add extension methods to another class, but only visible in a certain context?

In Kotlin, I want to add extension methods to a class, for example to class Entity. But I only want to see these extensions when Entity is within a transaction, otherwise hidden. For example, if I define these classes and extensions: interface…
Jayson Minard
  • 84,842
  • 38
  • 184
  • 227
23
votes
3 answers

Why can an instance of a class access private fields of another instance of its own type?

An instance of a class, in Java, can access private fields of a different instance of its own type, such as in the following listing: public class Foo { private int secret; public void bar(final Foo foo) { foo.secret = 100; } } What would…
Pétur Ingi Egilsson
  • 4,368
  • 5
  • 44
  • 72
22
votes
3 answers

Compile and execute Scala code at runtime

Is is possible to compile and execute scala code as a string at runtime either in Scala or in Java? My idea is to build a DSL using Scala then let Java programmers use the DSL inside Java. I heard that the class scala.tools.nsc.Interpreter can do…
Peter
  • 509
  • 1
  • 3
  • 10
22
votes
1 answer

What's the difference between """ and ''' in terms of running a shell script within a Jenkins pipeline step?

In Jenkins pipeline, what's the difference between: sh """ ... ... ... """ and sh ''' ... ... ... ''' Thanks in advance
Itai Ganot
  • 5,873
  • 18
  • 56
  • 99
21
votes
5 answers

Are there technical reasons a Ruby DSL like RSpec couldn't be rewritten in Python?

The section below goes into more detail, but basically someone stated that the Ruby-written DSL RSpec couldn't be rewritten in Python. Is that true? If so, why? I'm wanting to better understand the technical differences between Ruby and…
Matthew Rankin
  • 457,139
  • 39
  • 126
  • 163
21
votes
5 answers

Is this Monster Builder a good Builder / Factory pattern for abstracting long constructors mixed with setters?

This is a human interface question about combining the step builder pattern with the enhanced or wizard builder patterns into a creational DSL. It uses a fluent like interface, although it uses method chaining, not cascading. That is, the methods…
candied_orange
  • 7,036
  • 2
  • 28
  • 62
20
votes
1 answer

What are features of ANTLR that XText Does not provide?

I just came across very nice tool Xtext to create DSL as well as IDE for editing. I did some search on the web and found people saying it does not provide all the features of ANTLR. I am using ANTLR as my parser generator. I am not even sure what…
Tasawer Khan
  • 5,994
  • 7
  • 46
  • 69
20
votes
2 answers

Duplicator Interpreter with HOAS

In section 2.3 of these really cool notes on tagless final interpreters for DSLs, Oleg Kiselyov shows how to solve the problem of parsing a serialized DSL expression once, and interpreting it multiple times. Briefly, he shows that "fake first-class…
crockeea
  • 21,651
  • 10
  • 48
  • 101