An interesting subcategory of declarative programming languages is Domain Specific Languages (DSLs). DSLs are often thought of as mini-languages, specifically crafted to fit the use cases of a specific domain. This makes them very convenient and well suited for a particular problem type, but not for general-purpose computing. A few examples of popular DSLs include:
- HTML
- SQL
- YACC parser language
- MATLAB
In the following snippet, we'll see an example of a typical Hello World program written in HTML:
<html>
<header><title>This is title</title></header>
<body>
Hello world
</body>
</html>
HTML is a great example of a domain-specific language. It's highly optimized and specific to the task of defining how elements should be structured and styled within a web page. Although HTML is highly useful and popular, you wouldn't want to apply HTML to the task of building a scalable backend service, for example.
DSLs exist to make specific tasks easier. Kotlin DSLs exist for testing, the Gradle build system, defining HTML, and for other domains. You'll learn much more about creating your own custom DSLs in Chapter 11, Building Your Own Tools – Domain-Specific Languages (DSLs).