Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[SnowOne 2025] Дмитрий Черкасов: "Kotlin Fronte...

[SnowOne 2025] Дмитрий Черкасов: "Kotlin Frontend: как создавать фулстек-приложения с UI и не выглядеть фриком"

Затронем холиварную тему: как бэкенд-разработчику правильно и удобно писать фронт и какие есть решения для этого.

Ktor HTML Templates? Vaadin Kotlin DSL? React? Что выбрать и как не погрязнуть в бесконечном списке технологий, чтобы написать свой фронтенд.

Видео: https://youtu.be/QBtji0qpvqc

Avatar for jugnsk

jugnsk

May 08, 2025
Tweet

More Decks by jugnsk

Other Decks in Programming

Transcript

  1. Activities: ▪ Java /JVM ▪ Cloud / Microservices ▪ Jmix

    Framework, OpenIDE, OpenBPM ▪ Different PL ▪ Asio & guitars Cherkasov Dmitry Java Backend dev Jmix DevRel About 2
  2. How to write client properly being Java Dev? 3 ▪

    Java Dev ▪ Don’t know JS ▪ Build frontend
  3. How to write client properly? ▪ Template Engines ▪ Client

    Frameworks ▪ React / Next.js ▪ Vue / Nuxt.js ▪ Angular ▪ Vaadin + Spring Boot ▪ Jmix ▪ Native development 4
  4. How to write client properly? ▪ Ktor & Kotlin DSL

    HTML ▪ Kotlin React ▪ Kotlin Vaadin DSL ▪ Kotlin + Jmix ▪ Compose Multiplatform 5
  5. Why Kotlin? ▪ Jmix: Kotlin as Platform ▪ DSL /

    Client code ▪ Improving & Expending 9
  6. Why Kotlin? ▪ Jmix: Kotlin as Platform ▪ DSL /

    Client code ▪ Improving & Expending ▪ More Stable 10
  7. Why Kotlin? ▪ Jmix: Kotlin as Platform ▪ DSL /

    Client code ▪ Improving & Expending ▪ More Stable ▪ Hype-train 11
  8. End

  9. Kotlin HTML • Ktor ◦ Kotlin HTML ◦ Kotlin CSS

    ◦ Kotlin HTMX ◦ Kotlin.js 15
  10. • Mapping • Type-safe • Dynamic build • Integrated BI

    ▪ SSR Component ▪ Server-Side Rendering ▪ PHP? Kotlin HTML: Server Side Render 21
  11. Kotlin SSR: Adding more magic • Kotlin CSS DSL: ◦

    Static CSS ◦ Dynamic CSS ◦ Theme import 26
  12. Kotlin SSR: Adding more magic • Kotlin CSS DSL: ◦

    Static CSS ◦ Dynamic CSS ◦ Themes • Kotlin HTMX 27
  13. Kotlin SSR: Adding more magic • Kotlin CSS DSL: ◦

    Static CSS ◦ Dynamic CSS ◦ Themes • Kotlin HTMX ◦ Interactivity
  14. Kotlin SSR: Adding more magic • Kotlin CSS DSL: ◦

    Static CSS ◦ Dynamic CSS ◦ Themes • Kotlin HTMX ◦ Interactivity • Community Libs: 29
  15. Kotlin SSR: Adding more magic • Kotlin CSS DSL: ◦

    Static CSS ◦ Dynamic CSS ◦ Themes • Kotlin HTMX ◦ Interactivity • Community Libs: ◦ Kotlinwind.css ◦ … 30
  16. Kotlin SSR: Adding more magic • Kotlin CSS DSL: ◦

    Static CSS ◦ Dynamic CSS ◦ Themes • Kotlin HTMX ◦ Interactivity • Community Libs: ◦ Kotlinwind.css ◦ … • JS: 31
  17. Kotlin SSR: Adding more magic • Kotlin CSS DSL: ◦

    Static CSS ◦ Dynamic CSS ◦ Themes • Kotlin HTMX ◦ Interactivity • Community Libs: ◦ Kotlinwind.css ◦ … • JS: ◦ Unsafe JS 32
  18. Kotlin SSR: Adding more magic • Kotlin CSS DSL: ◦

    Static CSS ◦ Dynamic CSS ◦ Themes • Kotlin HTMX ◦ Interactivity • Community Libs: ◦ Kotlinwind.css ◦ … • JS: ◦ Unsafe JS ◦ Raw JS 33
  19. Kotlin SSR: Adding more magic • Kotlin CSS DSL: ◦

    Static CSS ◦ Dynamic CSS ◦ Themes • Kotlin HTMX ◦ Interactivity • Community Libs: ◦ Kotlinwind.css ◦ … • JS: ◦ Unsafe JS ◦ Raw JS ◦ Compiled JS from Kotlin 34
  20. kotlinx.html • User request • Server handle • Http Request

    • Finds target route • Route code invoking • DSL already build as AST • Transforming AST to HTML • HTML returns to User DSL Code HTML In-Memory Tree Runtine Transform 35
  21. Kotlin HTML DSL - results • Client & Server •

    Fast performance (compare to template engines) • “Single Page Application” • Easy • Generic • Speed - HTML/CSS • No config for build tools (minify, chunk, etc) • Frontend knowledge • Small community - no libs • Security - JS 43
  22. Project creation • Kotlin Project: ◦ Js Project / Multiplatform

    Project ◦ Kotlin-wrappers ◦ HTML in resources 50
  23. Project creation • Kotlin Project: ◦ Js Project / Multiplatform

    Project ◦ Kotlin-wrappers ◦ HTML • React.kt DSL ◦ Main 51
  24. Project creation • Kotlin Project: ◦ …. • React.kt DSL

    ◦ Main func ◦ App component ▪ useState 53
  25. Project creation • Kotlin Project: ◦ …. • React.kt DSL

    ◦ Main func ◦ App component ▪ useState ▪ useEffect 54
  26. Project creation • Kotlin Project: ◦ …. • React.kt DSL

    ◦ Main func ◦ App component ▪ useState ▪ useEffect ▪ Inline lambda 55
  27. Project creation • Kotlin Project: ◦ …. • React.kt DSL

    ◦ Main func ◦ App component ▪ useState ▪ useEffect ▪ Inline lambda ▪ DSL 56
  28. Project creation • Kotlin Project: ◦ …. • React.kt DSL

    ◦ Main func ◦ App component ▪ …. • Custom Components 57
  29. Project creation • Kotlin Project: ◦ …. • React.kt DSL

    ◦ Main func ◦ App component ▪ …. • Custom Components 58
  30. React.kt • Source Kt -> JS • Links Kt Wrappers

    -> JS • Source + Wrappers -> Client JS • Client JS -> Bundling WebPack • Dist Code -> Node.js Kotlin SRC IR Kotlin JavaScript ES WebPack Kotlin API for ES (KW) DevServer JS API Dist Code 60
  31. Kotlin React - results • Type - safe • Complex

    frontend • Any solution • Dev UX (optional) • Performance ◦ React - quick render ◦ Node.js - fast performance •Huge knowledges ◦ JVM -> V8 •Configuration •Cost & Time •JB Support •Small community 61
  32. • Optimization • Modern UI • Shadow DOM • Headless

    Java-JS/TS • Secured RPC • React • Lit.js • Mobile • Progressive Web Application • Java • Kotlin 63
  33. Vaadin - results • Easy 2 pro • Fullstack •

    Secured front • Dev Speed • Learn curve • Shoot your knee • Stateful 73
  34. Jmix 2 • High-level Framework • Spring boot • UI

    - vaadin • Dev speed • Full secured • Domain based 75
  35. Jmix development with Kotlin • DSL • Ui Thread •

    Null-safe • Fragments • Jmix = Dev Speed • Kotlin = Dev Speed • Kotlin + Jmix DSL 81
  36. Jmix on Kotlin - results • MVC • Agility •

    Secured fullstack • Dev Speed x2 • IntelliJ plugin • Dev Ex • Learn curve x2 • Debug • Stateful • Harder migration 83
  37. Compose • Jetpack Compose • KMP • Compose MP •

    IOS Focus • JavaScript WebAsm 88
  38. Compose • Jetpack Compose • KMP • Compose MP •

    IOS Focus • JavaScript WebAsm 89
  39. Compose Multiplatform - results • Cross-platform • Security • No

    JavaScript • Fast • Stable & Support by JB • Web Assembly • JS utilize • Dev Tools • Relatively new • Implement each platform • Mobile first - web second 96
  40. Summary • Kotlin HTML • Kotlin React • Vaadin DSL

    Kotlin • Jmix + Kotlin • Compose Multiplatform 99
  41. Summary Tech / Feature Kotlin HTML Kotlin React Vaadin Kotlin

    DSL Jmix + Kotlin Compose MP Production Ready No No Yes Excellent Yes Dev UX Yes No No Yes Excellent Fast Performance Yes Excellent No No Yes 100