Kotlin DSL: The Charming Parts
Freddie Wang & Shengyou Fan
Who am I
Who am I
Agenda
What’s DSL
Designed for a particular application domain, not for general-purpose
External and Internal DSL
Why Kotlin DSL
Kotlin Syntax
Top level function
Extension functions
Lambda with receiver
Infix notation
Real world DSLs
Real world cases
Gradle Kotlin DSL
Gradle syntax
Kotlin Gradle DSL
Kotlin DSL for HTML
HTML DOM
kotlinx.html
Exposed SQL Framework
Exposed SQL DSL
Generated SQL
Ktor Web Framework
Ktor Routing DSL
Write your own DSL
Design a mini app
Define the SimpleApp
Design the syntax (1/3)
Design the syntax (2/3)
Design the syntax (3/3)
Run the DSL
Live Demo - Using ScriptEngine
Check it on github - https://github.com/wangyung/kscript-dsl-example
Q&A
More cases