Domain Specific Languages: How To Make Your Own

Demystifying DSLs once and for all —a surprising realization about DSLs, how to build DSLs in Kotlin, how every class actually defines its own DSL and a quick note about context receivers.

Gabriel Shanahan
7 min readOct 11, 2022

— — — — — — — — — — — — — — —

THE CURRENT VERSION OF THIS ARTICLE IS PUBLISHED HERE.

— — — — — — — — — — — — — — —

Tags: #FUNDAMENTAL CONCEPT #EXERCISE

This article is part of the Kotlin Primer, an opinionated guide to the Kotlin language, which is indented to help facilitate Kotlin adoption inside Java-centric organizations. It was originally written as an organizational learning resource for Etnetera a.s. and I would like to express my sincere gratitude for their support.

It is recommended to read the Introduction before moving on. Check out the Table of Contents for all articles.

In the previous article, we started off with a seemingly boring and mundane list builder, and with a few quick changes, transformed it into a DSL. Here it is for reference:

--

--