Pro Yearly is on sale from $80 to $50! »

Creating Internal DSLs in Kotlin

Creating Internal DSLs in Kotlin

Creating Internal DSLs in Kotlin

Transcript

  1. Kotlin DSL Juan Guillermo Gómez @jggomezt

  2. Juan Guillermo Gómez • Co-Leader y Co-Founder of GDG Cali.

    • Founder DevHack. • Tech Lead Wordbox • Consultant and advisor on software architecture, cloud computing and software development. • Experience in several languages and platforms. (C, C#, Java, NodeJS, android, GCP, Firebase). • Google Developer Expert GCP & Firebase • BS in System Engineering and a MS in Software Engineering. • @jggomezt
  3. FOUNDATIONS

  4. ➢ Open-sourced since 2012. ➢ Developed by JetBrains. ➢ Version

    1.0 in 2016. ➢ Modern programming language ➢ Object Oriented. ➢ Statically typed. ➢ Less code with fewer bugs. ➢ Lambdas and properties. ➢ Nullable and non-nullable data type. ➢ Remove a lot of boilerplate from code. ➢ Readability. ➢ Functional constructs. ➢ Use Java Libraries. ➢ Immutability. Kotlin
  5. ➢ Computer language specialized to a particular application domain. ➢

    Contrast General Purpose Language ➢ Examples: HTML, R, SQL, VHDL ➢ BQL ---> Booking Query Language ??? Domain Specific Language
  6. ➢ External DSL vs Internal DSL ➢ Externals are implemented

    via an independent interpreter or compiler. LaTex ➢ Internals are typically implemented within a host language as a library. Domain Specific Language
  7. ➢ Context help to remove the noise. ➢ Ability to

    continue a conversation. ➢ You need fewer words you can be very expressive in a context. ➢ DLS is important to carry the context. ➢ Fluency is easy to read, it doesn’t feel like code. Context and Fluency
  8. Kotlin DSL Examples

  9. ➢ Nature of the language is very fluent. ➢ Optional

    semicolon. Semicolons break the flow. ➢ Drop () and . using infix notation. ➢ Extensions method. ➢ Lambda -- no () for passing last lambda. ➢ Implicit receivers. Kotlin DSL Capabilities
  10. DEMO

  11. REFERENCES ❖ https://www.youtube.com/watch?v=JzTeAM8N1-o ❖ https://www.youtube.com/watch?v=Rvx_BfG3NDo&t=516s ❖ https://github.com/fkorotkov/k8s-kotlin-dsl

  12. GRACIAS !! @jggomezt