Wrapping Up
The fluency and the power of Kotlin makes it a great language to create internal DSLs. And the ability to assign a context object for the execution of lambdas gives Kotlin a distinctive advantage as a host language for DSLs, compared to other statically typed languages. Designing a DSL with good fluency can be challenging, but with a good understanding of the various techniques to bring forward fluency and a good dose of patience, you can find your way to design for the fluency you desire.
Since it’s a statically typed language, Kotlin offers type safety when it comes to using DSLs. This has the benefit of failing fast. Also, using DSL marker annotations, you can improve error checking by restricting fluent calls to immediate receiver ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access