vjug24 - spring boot and kotlin, a match made in heaven
TRANSCRIPT
WHY SPRING BOOT?
@nicolas_frankel #kotlin #springboot 4
Convention over configuration
• Kickstart a project in minutes, not days
Out-of-the-box features
•Actuator
KOTLIN
@nicolas_frankel #kotlin #springboot 7
Open Source
Compiles to
• JVM bytecode
• JavaScript
•Native (experimental)
A "simpler Scala"
@nicolas_frankel #kotlin #springboot
KOTLIN MAIN FEATURES
@nicolas_frankel #kotlin #springboot 8
Functional and object-oriented
Statically typed
Null safety
No checked exceptions
Named & optional arguments
Lambdas
Extension functions more later
Java compatibility
(And more...)
@nicolas_frankel #kotlin #springboot
KOTLIN MAIN BENEFITS
@nicolas_frankel #kotlin #springboot 9
More expressive than Java
Improved OO
Functional too
HELLO KOTLIN!
package hello // no semicolons
// namespace-level functions
// types on the right
// no special syntax for arrays
// optional return type
fun main(args: Array<String>) {
println("Hello Kotlin!")
}
@nicolas_frankel #kotlin #springboot 10@nicolas_frankel #kotlin #springboot
THE KILLER FEATURE: EXTENSIONS
@nicolas_frankel #kotlin #springboot 11
Extension methods
Extension properties
EXTENSION METHOD
@nicolas_frankel #kotlin #springboot
Add new methods on an existing type
Called like a method on the type
Translated to static Utilmethod in the bytecode
12
SPRING WEB 5 FUNCTIONAL & KOTLIN
@nicolas_frankel #kotlin #springboot 14
https://docs.spring.io/spring/docs/current/spring-framework-reference/languages.html#kotlin-bean-definition-dsl