https://gitlab.com/asarazan/kotlinconf18
Next Level DSLs
Configure your app the Kotlin way!
Aaron Sarazan CTO - Stencil Ltd. aaron@stencil.ltd
Next Level DSLs Configure your app the Kotlin way! Aaron Sarazan - - PowerPoint PPT Presentation
Next Level DSLs Configure your app the Kotlin way! Aaron Sarazan CTO - Stencil Ltd. https://gitlab.com/asarazan/kotlinconf18 aaron@stencil.ltd Isolated Feature Development A Plugin Its like an app, just smaller Android Manifest Plugin
https://gitlab.com/asarazan/kotlinconf18
Configure your app the Kotlin way!
Aaron Sarazan CTO - Stencil Ltd. aaron@stencil.ltd
It’s like an app, just smaller
Android Manifest
Plugin DSL
Plugin DSL
Plugin DSL
Plugin DSL
Plugin DSL
Back to Basics
Help! What’s a DSL?
When you really wish your language could do the thing.
Help! What’s a DSL?
Help! What’s a DSL?
Help! What’s a DSL?
Podfiles
Help! What’s a DSL?
Domain Specific Language
white space
Help! What’s a DSL?
Domain Specific Language
Help! What’s a DSL?
Domain Specific Language
Help! What’s a DSL?
Domain Specific Language
Help! What’s a DSL?
Domain Specific Language
GRADLE!
Here’s How It Works
Here’s How It Works
Here’s How It Works
Experience Get!
Why Kotlin?
Type-Safe Builders
Kotlin is made for DSLs
When Should I Make a DSL?
Anko
Anko
This is Really Unpleasant
...and there has to be a better way.
ALWAYS a candidate for DSLs
Readability
Work Backwards
Start from the result that you want to enable ...then write the code that enables it!
Start With Builders
Immutability with a side of Java-friendliness!
@DslMarker
Prevent Scoping Mishaps!
Good Hygiene
○ Plugin.kt ○ PluginLambdas.kt
○ String, Int, etc.
Good Hygiene
○ Plugin.kt ○ PluginLambdas.kt
○ String, Int, etc.
So Who’s Ready?
Follow Along At Home
aaron@stencil.ltd https://gitlab.com/asarazan/kotlinconf18
DSLs EVERYWHERE
Kotlin’s Strongest Metaphors
Applied to Java’s biggest bummers
How Did We Get Here?
Value Types & Structs!!!
Configure your app the Kotlin way!
Aaron Sarazan CTO - Stencil Ltd. aaron@stencil.ltd
https://gitlab.com/asarazan/kotlinconf18
I can’t wait to get home and try out {AWESOME NEW FEATURE}
Configure your app the Kotlin way!
Aaron Sarazan CTO - Stencil Ltd. aaron@stencil.ltd
https://gitlab.com/asarazan/kotlinconf18
Follow Along At Home
Why Kotlin?