9

Kotlin DSLs

Men build too many walls and not enough bridges.

Joseph Fort Newton

Domain-specific languages (DSLs) regularly come up in discussions related to modern languages like Kotlin and Scala because these allow creating simple DSLs quickly within the language. Such internal DSLs can greatly improve code readability, development efficiency, and changeability. This chapter introduces DSLs and how to create them in Kotlin. It also explores the two most popular Kotlin DSLs on Android, namely a Kotlin DSL for Gradle build configurations and one for creating Android layouts.

Introducing DSLs

DSLs are by no means new; research goes back decades1 and is only increasing in recent times, from language modeling in general2 to DSLs in particular. ...

Get Kotlin for Android App Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.