Domain Specific Language Kotlin
Kotlin dsl kotlin provides first class support for dsls which allows us to express domain specific operations much more concisely than an equivalent piece of code in a general purpose language.
Domain specific language kotlin. One of these features i also wrote about on this blog is called function literals with receiver others are the invoke convention or infix notation in this article i will show how to create a kotlin dsl by introducing a library that exposes a. There are a wide variety of dsls ranging from widely used languages for common domains such as html for web pages down to languages used by only one or a few pieces of software such as. Its api aligns very closely with natural language and the syntax of hl7v2 as often seen in specifications and requirements so that translation from the language of the hl7 world into the language of the developer s world becomes redundant. A general purpose language such as kotlin or java on the other hand can be used in multiple parts of one application.
In this course kotlin fundamentals. There are several domain specific languages that we re already familiar with like sql for example. Kotlin s static typing makes it great for creating dsls. At the moment i m keeping my queries as multi line strings but i.
Basically a dsl is a language that focuses on just one particular part of an application. A domain specific language dsl is a computer language specialized to a particular application domain this is in contrast to a general purpose language gpl which is broadly applicable across domains. The kotlin based hl7v2 dsl provides a unique programming interface for handling hl7v2 messages. Here s how to use one to set up ssl tls connections in comparison to the more verbose java language.
Designing and implementing dsls requires thinking differently about your code and utilizing a suite of kotlin features which make dsls practical. This playground was created on tech io our hands on knowledge sharing platform for developers. Domain specific languages you will learn the kotlin features and implementation techniques for dsls. Kotlin as a programming language provides some very powerful features which allow the creation of custom internal domain specific languages dsl.
Writing a graphql domain specific language dsl in kotlin by alessandro diaferia i ve recently spent some time testing a graphql endpoint against a few queries. In this tutorial you ll create dsls to show android dialogs in different dsl styles and data models you need to use for the application.