DEV Community

Cover image for What is a Domain Specific Language (DSL)?
Hady Walied
Hady Walied

Posted on

What is a Domain Specific Language (DSL)?

Some History

back in November 2004, Sergey Demitriev, the CEO of Jetbrains, published published an articled titled “language oriented paradigm: the next programing paradigm” from which started this new wave of thoughts about the concept of creating a domain “field” specific language that gives a higher level of abstraction that can be more optimized for this specific type of field, a language that takes the concepts of a field and turn them into reproducible, easy to understand and custom syntax.

Why do DSLs exist ?

all right, let me tell you a small story about two friends of mine, let’s call them Ebs and Kemo, Ebs is an analog electronics engineer who is a very talented engineer, while Kemo is our trusted Software Engineer who is the Lead Software engineer of the group, and pretty much our tech guru,
so one day Ebs wants to simulate an electronic circuit but he doesn’t have the required programming skills to do so, so he goes to Kemo and asks him to write the simulation program for him and so does Kemo but he missed up some edge cases of the circuit and so the simulation produced false results and iterates a lot on the code-base with Ebs till they reach a satisfying result.
at this point Kemo thinks to him self and says why don’t I with the help of Ebs write a software that eases the use of programming for Ebs to write as many simulations and produce the required results using it, at this point DSL comes to the rescue.

if you have a method that can convey the domain specifics easily in a language that is kinda aligned with this specific field, this makes the thought process more clear, because your code hides implementation specifics inside separating the essentials from the complex clutter.

Where can we find DSLs?

DSLs are found in the wild a lot, android studio for an instance uses a DSL for Building and testing android applications using the build system named “Gradle”, as an junior android developer doesn’t have to be concerned with how the application build process is done, he just puts instructions to get some library or to apply some plugins and voi la, the process works like a charm.

also there is Groovey with it’s Closures that helps building a DSL engine and resolve it using JVM magic.

Where can we start ?

you can check this guide here by the one and only Martin Fowler

DSL Guide

also don’t forget to check this great video on how to build a DSL Engine in Groovey by Szymon Stepniak

You Wouldn't Believe How Simple Writing Groovy DSL Is 🤯 Let's Do It In 20 Minutes 🕓

and check this article from 2004 that I mentioned earlier

language oriented paradigm: the next programing paradigm

Photo by AXP Photography on Unsplash

Top comments (0)