What are Domain Specific Languages (DSLs)?
They are everywhere...
First, what is Domain Specific Language?
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.
This is the nice and short definition of a DSL. But then
How are Domain Specific Languages different from "real" programming languages?
A Domain specific language is usually less complex than a general-purpose language, such as Java, C, or Ruby. Generally, DSLs are developed in close coordination with the experts in the field for which the DSL is being designed. In many cases, DSLs are intended to be used not by software people, but instead by non-programmers who are fluent in the domain the DSL addresses.
So both quotes come from Jetbrains MSP page: jetbrains.com/mps/concepts/domain-specific-...
I added emphasis on experts as they are in the center of DSL development process. DSL is created with their help and for them to easily express domain knowledge in a way that is easy to understand by both humans (experts) and computers.
So let's look on examples from first page of Google results for phrase "Domain Specific Language" just to keep this article simple, and who is actually looking beyond first page?
- GameMaker Language
- ColdFusion Markup Language
- Erlang OTP
- Unreal Engine before version 4 and other games
- sh, Bash, CSH, and the likes for *nix; MS-DOS, Windows Terminal, PowerShell for Windows
- SQL and its variants
- Verilog, VHD
- Maven, Gradle
- MATLAB (commercial), GNU Octave, Scilab
- Lex, YACC, GNU Bison, ANTLR
And so one
There is a pattern in all those examples, they are all referring to programming in some way. As in Domain Specific Programming Language. I think we can do better. If someone is Erlang, ANTLR (irony), T-SQL, YACC expert then he can programming :)
Different set of examples
All examples are correct, or at least I'll not argue with them. But let's bring domain experts closer to our world (computers) and let's do something together, I know strange new worlds.
This is a clear example of DLS outside the computer realm, used for years to write music. Composers us them to compose music - and they are the experts. We can help them and digitalize those notes and feed them for example to MIDI players or help them convert it from single instrument to band or orchestra.
A chemical equation is the symbolic representation of a chemical reaction in the form of symbols and formulae, wherein the reactant entities are given on the left-hand side and the product entities on the right-hand side with a plus sign between the entities in both the reactants and the products and an arrow that points towards the products, and shows the direction of the reaction
Chemist know what to expect from them and what products look like. ChemDSL (made up name) can convert this notation to visual notation.
Take a look at en.wikipedia.org/wiki/Simplified_molecular-..
This list can go and go.
- Mathematical equations, check what Wolfram can do with them
- Human languages - NLP - Natural Language Processing - it's a thing
- Mathematical equations - Physics as some as well
- Phonetic notation - tells you how to spell words
- Sign language - for telling without spoken words
- Baseball score keeping - I'm surprised to: en.wikipedia.org/wiki/Baseball_scorekeeping..
- chess notations - en.wikipedia.org/wiki/Chess_notation#Notati..
- dance and juggling - few actually
- slangs - urbandictionary.com ;)
They are everywhere in or daily lives and almost every one uses them, no matter where are you or who are you. So next time, when someone tells you that they don't use DSL - tell them they probably do.
And when you are lucky they do it for business and some automation, visualization, transformation or version control may be handy, and you can help them with the right tool.
Did you find this article valuable?
Support Krzysztof Drozd by becoming a sponsor. Any amount is appreciated!