Kotlin for Internal DSLs

Kotlin is a wonderful language for creating internal DSLs. Static typing generally poses some strong limitations on a language’s ability to serve as a host for internal DSLs. Surprisingly, though, some of Kotlin’s unique capabilities not found in other statically typed languages push the limits to make creating internal DSLs not only possible but a pleasant experience as well. Let’s quickly review some of the capabilities of Kotlin that will serve as your allies when designing DSLs.

Optional Semicolon

Kotlin doesn’t insist on semicolons—see Semicolon Is Optional. That’s a clear benefit for fluency. A semicolon disrupts flow and is noise in a lot of situations. Not having to use it is especially critical for creating ...

Get Programming Kotlin now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.