One day Mickey saw Minnie sitting at the beach
Mickey – Hey Minnie
Minnie – Hi Mickey
Mickey – What are you doing here
Minnie – Came here to relax, feeling exhausted
Mickey – What is keeping you busy
Minnie – I need to explain DSL (Domain Specific Language) to my class tomorrow and I have been reading about it at the library but did not get it properly
Mickey – Oh, don’t you worry, I am here now, You understand better with a story
Minnie – Here we go
Mickey – Have you used a hammer
Minnie – Yes, of course
Mickey – Ok, what all can you do with a hammer
Minnie – Lots of things, fix nails on the wall, nail pushing, pulling, assembling furniture, bending, shaping, general carpentry, etc
Mickey – Can you open a beer bottle with a hammer
Minnie – Well, may be tricky, but I can
Mickey – Yes, exactly, you can but it can be difficult, dangerous, time-consuming, not very efficient, etc. It’s better to use a bottle opener that is created for this specific purpose
Minnie – Yes, you are right
Mickey – So bottle opener is like a DSL created for a specific purpose
Minnie – Give me some real-time example
Mickey – Ok! Do you know SQL (Structured Query Language)
Minnie – Not really deep, but I know its a language used to query databases
Mickey – Great, so SQL is created for a specific purpose i.e. query databases, unlike any general-purpose language like Java or Python
Minnie – So is SQL a DSL
Mickey – Yes exactly
A domain-specific language (DSL) is a language meant for use in the context of a particular domain
like SQL for Database Domain
A domain could be a business context (e.g., banking, insurance, etc.) or an application context (e.g., a web application, database, etc.)
A DSL does not attempt to please all. Instead, it is created for a limited sphere of applicability and use, but it’s powerful enough to represent and address the problems and solutions in that sphere
A good example of a DSL is HTML. It is a language for the web application domain
Minnie – Tell me some examples of DSL
Mickey –
- SQL databases
- HTML – web layout
- CSS – style web
- XPath – XML nodes selection
- UML – visual modeling
- Gherkin – A DSL to define functional tests
Minnie – What are some examples for DSL in the Business domain
Mickey – DSL can be created specifically to some business domains like
- Billing
- Salary Calculation
- Life Insurance
Minnie – Okay now I have enough data to present to my class tomorrow
Mickey – So now you understand DSL
Minnie – Yes, I feel so good now
Mickey – Shall we go home
Minnie – No, let’s just sit here and watch the sunset
Mickey – Ok
Minnie – You are my best friend, Mickey
Mickey – I am always here for you 🙂
about the author | more stories
References
https://en.wikipedia.org/wiki/Domain-specific_language
https://tomassetti.me/domain-specific-languages/
https://opensource.com/article/20/2/domain-specific-languages